Jump to content

javascript from html


jkm
 Share

Recommended Posts

Whether this actually produces desirable results depend on what is being done in the onclick script. If it is truly non-essential then clearing it is OK. It may do more elaborate processing however - you must study the code in each case,

The code in my previous reply will always work.

Dale

Dale - Finally got it to work. THANK YOU!
Link to comment
Share on other sites

Hi,

Thanks! Using the solution that removes the problem for me right now. However I can imagine other situations where a popup is needed to be evaluated to be able to decide which direction the script should take.

In the first time I was not able to get the

_IEAction($o_Button, "focus")

Send("{Enter}")

to operate. But this early saturday morning I got this to operate:

web_reboot()

Func web_reboot()
    $o_IE = _IECreate ()
    $URL = "http://localhost/test/testjavascript.html"
    ;open browser
    _IENavigate ($o_IE, $URL,0)
    _IELoadWait($o_IE)
    $o_form = _IEFormGetObjByName($o_IE, 'reboot')
    $o_Button = _IEFormElementGetObjByName($o_form, "submit")
    
    AdlibEnable("clickonthatpopup")     
    
    ;$o_Button.onclick=""
    ;$o_Button.click
    
    sleep(1000)
    _IEAction($o_Button, "focus")
    sleep(1000)
    Send("{Enter}")
    sleep(2000)
    AdlibDisable()
EndFunc

Func clickonthatpopup()
    ;MsgBox(0, "info", "all I want is to click the popup")
    If ControlFocus("Microsoft Internet Explorer","OK",1) Then
          ControlClick("Microsoft Internet Explorer", "", "Button1")
    EndIf
EndFunc

All I needed to do was to put in some sleep to wait for the popup. Maybe there is a better way to wait for this.

Thanks a lot for helping out. I really apreciate the help!

br

/jkm

Link to comment
Share on other sites

Right. You were disabling AdLib before it had a chance to fire.

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

  • 3 years later...

Right. You were disabling AdLib before it had a chance to fire.

Dale

Hi Dale,

I have the same problem with pop up java script window.

I am writing a script to login to a server, but stuck at the pop msgbox. I must click on the button to continue. However, it seems can be solved by using set

;$oReboot.onclick = "" ; I suppose this is to clear link onclick event, so that the pop msgbox won't come up.

But what I want to do is click the ok button on the pop msgbox, not clear the onclick event. is there any way around it?

BTW: I have tested the example 2 of IEAction, find it also not work :

; Wait for Alert window, then click on OK

WinWait("Windows Internet Explorer", "ExampleFormSubmitted")

ControlClick("Windows Internet Explorer", "ExampleFormSubmitted", "[CLASS:Button; TEXT:OK; Instance:1;]")

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