javascript - "InstallTrigger" is not defined -
javascript - "InstallTrigger" is not defined -
in html page have code this, have installed extension if browser firefox:
if (/firefox[\/\s](\d+\.\d+)/.test(navigator.useragent)) { //relevant code installtrigger.install(installxpi); } it works fine in every browser. when same page used through htmlunit framework , using browserversion.firefox_3_6 argument in webclient. shows error there:
com.gargoylesoftware.htmlunit.scriptexception: wrapped com.gargoylesoftware.htmlunit.scriptexception: wrapped com.gargoylesoftware.htmlunit.scriptexception: referenceerror: "installtrigger" not defined. any thought this?
this reminder you: don't utilize browser detection, utilize feature detection. issues code:
installtrigger feature of gecko engine, not firefox. explicitly looking "firefox" in user agent string , might exclude other browsers based on gecko engine (there e.g. seamonkey, k-meleon, camino). user agent strings can spoofed apparently htmlunit doing - claims firefox despite using different browser engine. code run problem then. here how properly:
if ("installtrigger" in window) { // gecko platform, installtrigger available installtrigger.install(installxpi); } javascript firefox htmlunit
Comments
Post a Comment