Opening A HREF Link on windows?

Hi folks!

I have a webpage loaded on an HTMLViewer, everything work fine, but I noticed some curious thing.

I made a button with and ExceuteJavascript in order to Click an “A HREF” link in a webpage: Log Out

The source code says: <a id="ctl00_LnkBtnCierraSesion" href="javascript:__doPostBack('ctl00$LnkBtnCierraSesion','')">Log Out</a></td>

For do it I have two ways (Using DOM’s Javascript & jQuery):

DOM:

Dim LogOutSAT As String= "LogOutSAT();" _ +"function LogOutSAT() {" _ +" document.getElementById('ctl00_LnkBtnCierraSesion').click();" _ +"};" HTMLViewer1.ExecuteJavaScript(LogOutSAT)

jQuery:

Dim LogOutSAT As String= "LogOutSAT();" _ +"function LogOutSAT() {" _ +" $('#ctl00_LnkBtnCierraSesion')[0].click();"_ +"};" HTMLViewer1.ExecuteJavaScript(LogOutSAT)

In both cases Works flawlessly on Mac, when I click the button, do the click without problem and Log Out form this website.

But when I do this on windows, nothing happens.

Any ideas?

Try putting the function definition before the call to it and see if that does anything (quick cut and paste edit).

Dim LogOutSAT As String= "" _ +"function LogOutSAT() {" _ +" document.getElementById('ctl00_LnkBtnCierraSesion').click();" _ +"}; LogOutSAT();" HTMLViewer1.ExecuteJavaScript(LogOutSAT)

If that doesnt work, try calling javascript:__doPostBack(‘ctl00$LnkBtnCierraSesion’,’’) directly from ExecuteJavaScript

If none of those work then its an IE security issue calling javascript. I’ve not played with it enough in Xojo to know about that, let me know how you get on.

Have you tried both renderers?

[quote=267517:@JulianS]Try putting the function definition before the call to it and see if that does anything (quick cut and paste edit).

Dim LogOutSAT As String= "" _ +"function LogOutSAT() {" _ +" document.getElementById('ctl00_LnkBtnCierraSesion').click();" _ +"}; LogOutSAT();" HTMLViewer1.ExecuteJavaScript(LogOutSAT)

If that doesnt work, try calling javascript:__doPostBack(‘ctl00$LnkBtnCierraSesion’,’’) directly from ExecuteJavaScript

If none of those work then its an IE security issue calling javascript. I’ve not played with it enough in Xojo to know about that, let me know how you get on.[/quote]
Thanks Julian.

As you said, I call Javascript directly from ExecuteJavascript and it works on both platforms:

Dim LogOutSAT As String= "LogOutSAT();" _ +"function LogOutSAT() {" _ +" javascript:__doPostBack('ctl00$LnkBtnCierraSesion','');" _ +"};" HTMLViewer1.ExecuteJavaScript(LogOutSAT)

Excellent Gerado!

Just remember if it is a site that you didn’t make they could change the name of the LnkBtnCierraSesion button in the future and break your code.

If its not your site you could probably find the name of the button (ctl00_LnkBtnCierraSesion) in code and call that.