Juvigy Posted September 14, 2010 Share Posted September 14, 2010 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. Link to comment Share on other sites More sharing options...
Authenticity Posted September 14, 2010 Share Posted September 14, 2010 #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) Link to comment Share on other sites More sharing options...
Juvigy Posted September 14, 2010 Author Share Posted September 14, 2010 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? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now