mlabs

I am using insertAdjacentHTML() to inject a block of javascript into a web page.

The script simply searches for some elements in a TABLE on the page and modifies the attribs on them. The script shows no UI.

PRB: The script doesn't always run upon injection. I have no clue why.

However, as soon as I insert a few alert() statements into the script .. then it *does* run .. EVERY TIME. How on earth could adding an alert() call affect things like this

TIA


Re: Internet Explorer Extension Development crazy behavior - PLEASE HELP

IECUSTOMIZER

Hi Mlabs,

Does this happen in IE6 SP1, SP2, IE7 popup blockers disabled. I am suspecting that a popup blocker is interigating your injected script and decides that if it contains alert statements, then it must be benign and does not stop its execution.

It seems strange to use a BHO to inject script into the document as this will be defeated when the user has chosen to disable scripting in their Internet Settings.

You BHO should be able to establish a reference to the current page's DOM, and from there you can manipulate the style attributes of elements.

Regards.






Re: Internet Explorer Extension Development crazy behavior - PLEASE HELP

mlabs

no .. no popup blockers...

when inserting a <SCRIPT> block, I read that it has to be of a very particular format :

<SPAN id='myScript'' style='position: absolute;'>&nbsp;</SPAN>

<SCRIPT LANGUAGE='JavaScript' defer>

..code

</SCRIPT>

in particular, the defer attribute needs to be there and further, incredibly, the &nbsp .. because aparently IE is doing some sort of parsing of the injected HTML and makes a decision whether to run it or not based on finding some UI in there..

Is this true

Could this have anything to do with my problem Literally, just adding an alert statement and changing nothing else.. seems to guarantee it to run...

is IE doing any other wierd parsing here

i am going crazy with this...





Re: Internet Explorer Extension Development crazy behavior - PLEASE HELP

mlabs

more clues .. maybe... clearing the cache between inserts seems to help.. sometimes..

i have no idea what is going on...

if any microsoft folks out there are reading this... some help would be greatly appreciated...





Re: Internet Explorer Extension Development crazy behavior - PLEASE HELP

IECUSTOMIZER

Hi,

Is your injected script well formed no missing line delimiters ';'

Download and install the debug toolbar - www.debugbar.com - it has a built in java script debugger that may be helpful. I suppose that you have set up IE for script debugging and have installed the MS script debugger

Are you running your BHO in debug or release mode (I think the debug environment uses a temporary cache)

Regards.






Re: Internet Explorer Extension Development crazy behavior - PLEASE HELP

mlabs

yes - it runs fine sometimetimes.. and other times not..

also i'm wondering now if adding the alert statement or flushing the cache actually did anything at all - its very inconsistent....

maybe insertAdjacentHTML has a bug It's as if it doesn't always guarantee to parse and run the stuff you are inserting...

i verified the doc readystate is 'complete'

now would be a good time to step in and comment Microsoft folks! Smile

IECUSTOMIZER wrote:

Hi,

Is your injected script well formed no missing line delimiters ';'

Download and install the debug toolbar - www.debugbar.com - it has a built in java script debugger that may be helpful. I suppose that you have set up IE for script debugging and have installed the MS script debugger

Are you running your BHO in debug or release mode (I think the debug environment uses a temporary cache)

Regards.