Jump to content

IE Click on text that is not an HREF?


orange
 Share

Recommended Posts

I am trying to get information from a web page that is session dependent, and whose link is determined by a javascript in the header.

Here are some excerpts of HTML that I am trying to parse.

this is the java in the header that navigates

<script type="text/javascript">
  function show_course(courseIndex) {
    window.open("https:mysub.mysite.com/socresultsingle?selectedIndex=" + Index, "_blank", 
                'width=600, height=500, location=1, menubar=1, resizable=1, scrollbars=1');
    return false;
  }
</script>

This function is refrenced in the rest of the HTML by this:

...<td nowrap onclick="show_course(0);">Click on this Text< ...

Note that there is no HREF to follow for _IEclickbytext, and that there is no "src=" for the _IEimgClick.

is there any way that I can click on this type of link by using IE.au3?

Any help here would be great.

Link to comment
Share on other sites

Option 1: You can walk the DOM object tree into the table and to the specific TD element and then use _IEAction($oTD, "click")

I'd go into more detail, but I'm betting you're going to like option 2 better...

_IENavigate($oIE, "java script:show_course(0)")

Dale

edit: strange... the board is insisting on putting a space between java and script... must be a protection against malicious code injection. It may work for you as it is or you may have to remove it after cut and paste

Edited by DaleHohm

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

Option 1: You can walk the DOM object tree into the table and to the specific TD element and then use _IEAction($oTD, "click")

I'd go into more detail, but I'm betting you're going to like option 2 better...

_IENavigate($oIE, "java script:show_course(0)")

Dale

edit: strange... the board is insisting on putting a space between java and script... must be a protection against malicious code injection. It may work for you as it is or you may have to remove it after cut and paste

well, at least for the time being this does not work, it does not redirect, but instead returns FALSE. so, at least I think that it is running the script. I'll mess around with it a bit. see where this goes.

thanks for the reply

EDIT -- Im really not sure what you mean about option 1 :whistle:

Edited by orange
Link to comment
Share on other sites

ive been working on this solidly for the last two days, and even with your suggestion over the last 45 minutes I haven't gotten anywhere. The best I can do is have the script tell me that I am FALSE. woot.

Can you go into more detail as to how the first option works?

Link to comment
Share on other sites

OK, here is a sample of doing Option 1:

$oTDs = _IETagNameGetCollection($oIE, "td")

$sTextToFind = "Click on this Text"

For $oTD in $oTDs 
    If String($oTD.innerText) = $sTextToFind Then
        _IEAction($oTD, "click")
        ExitLoop
    EndIf
Next

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

OK, here is a sample of doing Option 1:

$oTDs = _IETagNameGetCollection($oIE, "td")

$sTextToFind = "Click on this Text"

For $oTD in $oTDs 
    If String($oTD.innerText) = $sTextToFind Then
        _IEAction($oTD, "click")
        ExitLoop
    EndIf
Next

Dale

Thanks. It solves one problem.

However, now there is a popup coming up, and as it turns out the info that i need is in that popup. This new popup window shows even if the IECreate window is invisible.

Is there a way, now that we have the popup loaded, to get the info from it?

Link to comment
Share on other sites

_IENavigate($oIE, "java script:show_course(0)")

Dale

edit: strange... the board is insisting on putting a space between java and script... must be a protection against malicious code injection. It may work for you as it is or you may have to remove it after cut and paste

Hi,

I use:

$oIE.document.parentwindow.eval('show_course(0)')

HTH

Link to comment
Share on other sites

Hi,

I use:

$oIE.document.parentwindow.eval('show_course(0)')

HTH

this works too, and faster too. BUt i still have the problem of not being able to control the popup window. Is there a way to control the visibility of the popup and retrieve data from it?

Link to comment
Share on other sites

this works too, and faster too. BUt i still have the problem of not being able to control the popup window. Is there a way to control the visibility of the popup and retrieve data from it?

Hi,

Not sure but I suppose you have to 'hook-up' to the new browser-window...

Stuff to use is something like:

$x = ControlGetHandle("","","Internet Explorer_Server1")

$temp = __IEControlGetObjFromHWND($x);

$temp = ControlGetHandle(_IEPropertyGet($temp, "hwnd"), "", "Internet Explorer_Server1")

Local $oIE2 =_IEAttach ($temp, "HWND")

and then the usual with $oIE2...

Perhaps do some searching on one of those functions here on the forum

HTH

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