Sign in to follow this  
Followers 0
neo007

click a javascript link ?

13 posts in this topic

Hi everyone,

I'm new to Autoit. I've built some scripts to log in some accounts....

Now I'm working on a script that will click javascript link in IE.

For example:

The link shows "3". When mouse stops on it, status bar shows ""java script:{gopage(3);}".

I tried a code which failed:

#include <IE.au3>
$oIE = _IE_Example ("xxxxx")
$oSubmit = _IEGetObjByName ($oIE, "3", 0)
_IEAction ($oSubmit, "click")

I know I shouldn't use "_IE_Example ", but what should I use?

And there's another "link": it shows as a little triangle, and I look into its properties, the url is a .gif

How could I click it?

Thanks.

Share this post


Link to post
Share on other sites



_IEAttach

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I tried 2 codes, both failed:(nothing happens)

#include <IE.au3>
WinActivate("xxxx - Microsoft Internet Explorer")
$oIE = _IEAttach("xxxx")
_IENavigate($oIE, "java script:{gopage(3);}")

and

#include <IE.au3>
WinActivate("xxxx - Microsoft Internet Explorer")
$oIE = _IEAttach("xxxx")
$oSubmit = _IEGetObjByName($oIE, "3",0)
_IEAction ($oSubmit, "click")
Edited by neo007

Share this post


Link to post
Share on other sites

This also failed (nothing happens):

#include <IE.au3>
WinActivate("xxxx - Microsoft Internet Explorer")
$oIE = _IEAttach("xxxx")
_IELinkClickByText($oIE, "3")

Share this post


Link to post
Share on other sites

Can't really tell what the problem is by those three lines.

What's the error?

If it can't find the button, check the source of the page to get the name of it, or use Debugbar.

Share this post


Link to post
Share on other sites

If it can't find the button, check the source of the page to get the name of it, or use Debugbar.

It's not a button, but a link.

Just now I installed Debugbar. I dragged target on that link "3", the result is as the picture I grabbed. What should I do next?

post-30468-1198542949_thumb.gif

Thanks. Merry Christmas !!!

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

When you run it in Scite (F5), what's the error?

Also, Dale will have a better than I, so you might want to ask for him to help in the subtitle of the thread, maybe he'll see ;p

Also, since it's a javascript DOM object thingamjig, I think the right one would be _IEAction's Click, which I see you tried.

Edited by Nevin

Share this post


Link to post
Share on other sites

Can't tell from looking at the DebugBar picture if the link text is just the number 3 or if it has one or more spaces after it. If there are spaces, then you will be the source of your issue -- the text must match exactly. Even with the javascript, _IELinkClickByText should be fine since it is tied to a link (<a>).

If you have the link text correct, it is also possible that there are frames involved... DebugBar will help you see those if so.

It is also critical to know the messages in the SciTe console.

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

Share this post


Link to post
Share on other sites

Thanks.

Don't know how to edit subtitle in this forum, and, I want to change a method, so I'll post a new thread.

Thank you very much.

Share this post


Link to post
Share on other sites

If you intend to start a new thread with the same issue, I'd prefer you reply to my post first here so that we don't have to start over.

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

Share this post


Link to post
Share on other sites

Well, I have opened new thread already.....

I copy it here, too:

Could you please help me with this:

In a webpage, I wanna click a link "3" (which is "java script:{gopage(3);}") and IE will go to another page. I tried several codes and Nevin helped me a lot. Now I learned more and I think I should do it another way:

There's a input textbox(named "pagenum") in the page. On the right there's a button "GO". If I input "3" and press GO, the same result happens as clicking link.

I find out:

"GO" button's code is:

A href=java script:form1.submit()

IMG src=http://....../account_11.gif

There's some iframes in the page. All objects I'm dealing with is in "ifr_left";

Every iframe has a form named "form1".

So, I wrote this code:

#include <IE.au3>
WinActivate("xxxx - Microsoft Internet Explorer")
$oIE = _IEAttach("xxxx")
$oFrame = _IEFrameGetObjByName ($oIE, "ifr_left")
.....here, how to connect this $oFrame to $oForm ?
$oForm = _IEFormGetObjByName ($oIE, "form1")
$oText = _IEFormElementGetObjByName ($oForm, "pagenum")
_IEFormElementSetValue ($oText, "3")

My question is "how to connect this $oFrame to $oForm ?"

Thanks.

Share this post


Link to post
Share on other sites

Well, I have opened new thread already.....

I copy it here, too:

Could you please help me with this:

In a webpage, I wanna click a link "3" (which is "java script:{gopage(3);}") and IE will go to another page. I tried several codes and Nevin helped me a lot. Now I learned more and I think I should do it another way:

There's a input textbox(named "pagenum") in the page. On the right there's a button "GO". If I input "3" and press GO, the same result happens as clicking link.

I find out:

"GO" button's code is:

A href=java script:form1.submit()

IMG src=http://....../account_11.gif

There's some iframes in the page. All objects I'm dealing with is in "ifr_left";

Every iframe has a form named "form1".

So, I wrote this code:

#include <IE.au3>
WinActivate("xxxx - Microsoft Internet Explorer")
$oIE = _IEAttach("xxxx")
$oFrame = _IEFrameGetObjByName ($oIE, "ifr_left")
.....here, how to connect this $oFrame to $oForm ?
$oForm = _IEFormGetObjByName ($oIE, "form1")
$oText = _IEFormElementGetObjByName ($oForm, "pagenum")
_IEFormElementSetValue ($oText, "3")

My question is "how to connect this $oFrame to $oForm ?"

Thanks.

Once you get a reference to the frame you use it in place of the top level browser, $oIE.

E.g.:

#include <IE.au3>
$oIE = _IEAttach("xxxx")
$oFrame = _IEFrameGetObjByName ($oIE, "ifr_left")
$oForm = _IEFormGetObjByName ($oFrame, "form1")
$oText = _IEFormElementGetObjByName ($oForm, "pagenum")
_IEFormElementSetValue ($oText, "3")

Dale

P.S. PLEASE include the messages you get in the SciTe console when you report issues like this.


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

Share this post


Link to post
Share on other sites

I find much more errors.... I'll try to learn and check this code after some days....

Many thanks!!!

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