Sign in to follow this  
Followers 0
taren9k3

Set javascript var value

7 posts in this topic

#1 ·  Posted (edited)

<script>

var a=1

</script>

I have this script.

How to set a value to 123 by using autoit script.

thanks

Edited by taren9k3

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#include <IE.au3>

Dim $oIE, $oScripts, $oScript

$oIE = _IECreate('http://www.google.com/')
ConsoleWrite('a variable is: ' & IEEval($oIE, 'a') & @LF)
;$oScript = $oIE.document.scripts(2)
;ConsoleWrite(_IEPropertyGet($oScript, 'innerhtml') & @LF)
;IEEval($oScript, 'a=123')
IEEval($oIE, 'a=123')
ConsoleWrite('a variable is: ' & IEEval($oIE, 'a') & @LF)

; Thanks DaleHohm for the code.
Func IEEval($o_object, $s_eval)
    Return $o_object.document.parentwindow.eval($s_eval)
EndFunc   ;==>IEEval

Edited by Authenticity

Share this post


Link to post
Share on other sites

How do you know document.parentwindow.eval($s_eval)

Where can I find document.name.value,....

Can you tell me.

Share this post


Link to post
Share on other sites

Authenticity reply me! :):party:

Share this post


Link to post
Share on other sites

Hi, heh sorry for not replying here. I didn't know about it, it's from another thread the DaleHohm posted. It's not documented here yet but I believe that the Window object exposes it as well as the execScript method which, if I understand it correctly, does the same as eval.

Share this post


Link to post
Share on other sites

Thank for replying :))

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

How do you know document.parentwindow.eval($s_eval)

Where can I find document.name.value,....

Can you tell me.

That's only Java-Script:

http://www.w3schools.com/jsref/jsref_eval.asp

eval on the DOM-element document.parentwindow.

Edited by Stilgar

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