Sign in to follow this  
Followers 0
Juvigy

IE _IEHeadInsertEventScript troubles

3 posts in this topic

Hi Guys,

I am trying to insert some JS in a page.When i try:

$script = 'alert("some text");'
_IEHeadInsertEventScript ($oIE, "document", "onmousedown", $script)

It works. But if i try something more complicated like:

$script = 'function whichElement(e){var tname;tname=e.target.tagName;alert("You clicked on a " + tname + " element.");}'
_IEHeadInsertEventScript ($oIE, "document", "onmousedown", $script)

It doesnt.I tried also.

$oBody = _IETagNameGetCollection($oIE, "body", 0)
_IEDocInsertHTML($oBody, '<body onmousedown="whichElement(event)">', "afterbegin")
$script = 'function whichElement(e){var tname;tname=e.target.tagName;alert("You clicked on a " + tname + " element.");}'
_IEHeadInsertEventScript ($oIE, "document", "onmousedown", $script)

What am i doing wrong? The JS work - i tested it manually.

Share this post


Link to post
Share on other sites



#include <IE.au3>
$oIE = _IE_Example()
_IEHeadInsertEventScript ($oIE, "document", "ondrag", "return false;")
_IEHeadInsertEventScript ($oIE, "document", "onselectstart", "return false;")

$script = 'function whichElement(e){var tname;tname=e.srcElement.tagName;alert("You clicked on a " + tname + " element.");};whichElement(event);'
_IEHeadInsertEventScript ($oIE, "document", "onmousedown", $script)

Share this post


Link to post
Share on other sites

10x . I tried

$script = 'function whichElement(e){var tname;tname=e.srcElement.tagName;alert("You clicked on a " + tname + " element.");};whichElement(event);' but without the last js script line - whichElement(event) . Do i always have to call the function too? I kind of thought that the event triggers the function by itself?

Share this post


Link to post
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
Sign in to follow this  
Followers 0