NavigateComplete2 DOM state

Add-in Express™ Support Service
That's what is more important than anything else

NavigateComplete2 DOM state
 
Stephen Owens




Posts: 3
Joined: 2011-03-25
In my add-on I'm trying to get access to the DOM before any scripts in the page being loaded can run. I want to insert a new script as the first script to execute on the page.

So far my quest has lead me to the NavigateComplete2 event. When I handle this event the PDisp of the event arguments that I receive is pointing to the browser. For some simple web pages I can then get the Document member of that web browser object and use that to manipulate the downloaded document before any other scripts get to run. However in some cases the DOM of the returned document doesn't seem to be complete. In particular the Document.body member is null.

Two questions then. First, would you expect the DOM to be stable and complete when handling the NavigateComplete2 event? Should I be able to insert a new script at the top of the head during the handling of this event and expect it to be executed as the first script?

Second question. Is there a better way to access and modify the DOM from my add-on before any page scripts are run?
Posted 13 Jul, 2011 13:33:12 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Stephen,

The DOM is fully accessible in the DocumentComplete event. There is not any other reliable event to inject and execute scripts.
Posted 14 Jul, 2011 05:45:55 Top
Stephen Owens




Posts: 3
Joined: 2011-03-25
Okay, just to confirm then. I think you just said that what I want to do is not possible. Since in DocumentComplete the other scripts are already active. Can you confirm that is what you meant?
Posted 14 Jul, 2011 09:48:33 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Yes, right.
Posted 14 Jul, 2011 10:29:59 Top