Jump to content

Inject Javascript Into IE When onbeforeunload Event Exists


tphant0m
 Share

Recommended Posts

I'm trying to inject a bit of javascript into a page to change a few variables.

However the page has an onbeforeunload event.,

window.onbeforeunload = afunction;

<body onbeforeunload="afunction">

thus when i try put java script: lines into the address bar, this event fires (because it thinks im trying to navigate away from the page).

i have tried a _IEDocReadHTML then remove the events, then a _IEDocWriteHTML (and a _IEAction($oIE, "refresh")) so it actually loads up.

however when executing the refresh the onbeforeunload even still loads. (the page im trying to play with deflares a frameset (i understand i HAVE to do that refresh so it actually builds the frame set again).

i think im looking for some way to execute javascript in that browser instance via COM or something similar, anything that wont fireaway a navigate away style event.

any ideas would be great :P

Link to comment
Share on other sites

A "why?" woudl be a good inclusion.

In addition, the URL to the site in question would be helpful.

(of course, failure to provide both of the above lead to suspicion of bad motive.)

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Link to comment
Share on other sites

You could try overriding the current event with something like this:

$oIE.document.body.onbeforeunload=';'

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...