Jump to content

_IE problem with javascript changed source code, help!


Tiax
 Share

Recommended Posts

Hi,

I'm creating a script that is going to navigate through a webpage and record the time it takes to do certain stuff.

The problem I'm having is that there is javascript that edits the source code and adds the link I need to click but I can't click the element for some reason.

The original source code when the page is loaded:

<SPAN style="Z-INDEX: 100; COLOR: black" id=treeDiv class=smallDescription>

<DIV style="POSITION: absolute; WIDTH: 150px; TOP: 76px; LEFT: 10px" class=hide>Laddar menyn... </DIV>

</SPAN>

Ps. "Laddar menyn..." equals "Loading menu..." in Swedish.

And when the menu is loaded it's a bunch of divs with onclick attributes. For example:

<div style="z-index: 11; padding-left: 0pt; background-position: 120px 3px; background-image: url(/skins/Riksbyggen/images/i1.gif); padding-top: 1px; background-repeat: no-repeat; visibility: visible; top: 228px; left: 8px; background-color: rgb(213, 2, 2); color: white;" onmouseover="nodem8b1f22570b5f41e1a8ec997f4ecbcd50.mouseover()" onmouseout="nodem8b1f22570b5f41e1a8ec997f4ecbcd50.mouseout()" class="menuItem" id="divm8b1f22570b5f41e1a8ec997f4ecbcd50" onclick="nodem8b1f22570b5f41e1a8ec997f4ecbcd50.changeLoc();return false"> <img hspace="4" align="absMiddle" src="/menu/images/extLink.gif" class="extLinkImg"/>Edit menu</div>

I can't get the div with:

$oDiv = _IEGetObjById ($oIE, "divm8b1f22570b5f41e1a8ec997f4ecbcd50")

And I can't execute the onclick with:

$oIE.document.parentwindow.execScript('nodem8b1f22570b5f41e1a8ec997f4ecbcd50.changeLoc();return false')

I even tried making a exact copy of the div and clicking that element:

$sHTML = _IEDocReadHTML($oIE)
$sHTML = $sHTML & '<div style="z-index: 11; padding-left: 0pt; background-position: 120px 3px; background-image: url(/skins/Riksbyggen/images/i1.gif); padding-top: 1px; background-repeat: no-repeat; visibility: visible; top: 228px; left: 8px; background-color: rgb(213, 2, 2); color: white;" onmouseover="nodem8b1f22570b5f41e1a8ec997f4ecbcd50.mouseover()" onmouseout="nodem8b1f22570b5f41e1a8ec997f4ecbcd50.mouseout()" class="menuItem" id="divm8b1f22570b5f41e1a8ec997f4ecbcd50" onclick="nodem8b1f22570b5f41e1a8ec997f4ecbcd50.changeLoc();return false"> <img hspace="4" align="absMiddle" src="/menu/images/extLink.gif" class="extLinkImg"/>EleFHant</div>'
_IEDocWriteHTML ($oIE, $sHTML)

But nothing works. Someone plese help me?

Ps. It doesn't help if I wait with Sleep(5000) for the menu to load, it's still the same issue.

Link to comment
Share on other sites

Hi,

I'm creating a script that is going to navigate through a webpage and record the time it takes to do certain stuff.

The problem I'm having is that there is javascript that edits the source code and adds the link I need to click but I can't click the element for some reason.

The original source code when the page is loaded:

<SPAN style="Z-INDEX: 100; COLOR: black" id=treeDiv class=smallDescription>

<DIV style="POSITION: absolute; WIDTH: 150px; TOP: 76px; LEFT: 10px" class=hide>Laddar menyn... </DIV>

</SPAN>

Ps. "Laddar menyn..." equals "Loading menu..." in Swedish.

And when the menu is loaded it's a bunch of divs with onclick attributes. For example:

<div style="z-index: 11; padding-left: 0pt; background-position: 120px 3px; background-image: url(/skins/Riksbyggen/images/i1.gif); padding-top: 1px; background-repeat: no-repeat; visibility: visible; top: 228px; left: 8px; background-color: rgb(213, 2, 2); color: white;" onmouseover="nodem8b1f22570b5f41e1a8ec997f4ecbcd50.mouseover()" onmouseout="nodem8b1f22570b5f41e1a8ec997f4ecbcd50.mouseout()" class="menuItem" id="divm8b1f22570b5f41e1a8ec997f4ecbcd50" onclick="nodem8b1f22570b5f41e1a8ec997f4ecbcd50.changeLoc();return false"> <img hspace="4" align="absMiddle" src="/menu/images/extLink.gif" class="extLinkImg"/>Edit menu</div>

I can't get the div with:

$oDiv = _IEGetObjById ($oIE, "divm8b1f22570b5f41e1a8ec997f4ecbcd50")

And I can't execute the onclick with:

$oIE.document.parentwindow.execScript('nodem8b1f22570b5f41e1a8ec997f4ecbcd50.changeLoc();return false')

I even tried making a exact copy of the div and clicking that element:

$sHTML = _IEDocReadHTML($oIE)
$sHTML = $sHTML & '<div style="z-index: 11; padding-left: 0pt; background-position: 120px 3px; background-image: url(/skins/Riksbyggen/images/i1.gif); padding-top: 1px; background-repeat: no-repeat; visibility: visible; top: 228px; left: 8px; background-color: rgb(213, 2, 2); color: white;" onmouseover="nodem8b1f22570b5f41e1a8ec997f4ecbcd50.mouseover()" onmouseout="nodem8b1f22570b5f41e1a8ec997f4ecbcd50.mouseout()" class="menuItem" id="divm8b1f22570b5f41e1a8ec997f4ecbcd50" onclick="nodem8b1f22570b5f41e1a8ec997f4ecbcd50.changeLoc();return false"> <img hspace="4" align="absMiddle" src="/menu/images/extLink.gif" class="extLinkImg"/>EleFHant</div>'
_IEDocWriteHTML ($oIE, $sHTML)

But nothing works. Someone plese help me?

Ps. It doesn't help if I wait with Sleep(5000) for the menu to load, it's still the same issue.

Javascript Function Example

http://www.w3schools.com/js/tryit.asp?filename=tryjs_function1

onmouseover Event

http://www.w3schools.com/DHTML/tryit.asp?filename=trydhtml_event_onmouse

http://www.w3schools.com/js/tryit.asp?filename=tryjs_animation

#include <IE.au3>
$oIE = _IE_Example ("basic")

$Txt = "displaymessage('Hello World!')" & @CRLF & _
"function displaymessage(Text)" & @CRLF & _
"{" & _
"alert(Text);" & _
"}"
_IEHeadInsertEventScript ($oIE, "document", "onclick", $Txt)




;<h1 onmouseover="style.color='red'"
;onmouseout="style.color='black'">
;Mouse over this text</h1>

$Txt = "<h1 onmouseover=" & Chr(34) & "style.color='red'" & chr(34) & _
"onmouseout=" & chr(34) & "style.color='black'" & chr(34) & ">" & _
"Mouse over this text</h1>"
$oBody = _IETagNameGetCollection($oIE, "body", 0)
_IEDocInsertHTML($oBody, $Txt, "afterbegin")
Edited by wolf9228

صرح السماء كان هنا

 

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...