| View previous topic :: View next topic |
| Author |
Message |
CannedCheese
Joined: 21 May 2008 Posts: 85
|
Posted: Sun Aug 10, 2008 10:46 pm Post subject: Pass an ahk variable to a javascript continuation section |
|
|
This may be a stupid question, or it may not be possible. What I'm trying to do is pass a variable's contents to a javascript instruction that, for means of readability, I want to keep in a continuation section. I'm using tank's awesome IE7 functions...
This should work...
| Code: |
IE7_ExecuteJS(myPageHandle, "for (i = 0; x <>'" name "'; i++){x=(document.getElementById('Table1').childNodes[1].childNodes[i].innerText); y+=(document.getElementById('Table1').childNodes[1].childNodes[i].childNodes[1].innerText)};", "y")
|
[edit] I don't know, maybe it should be %name% instead...
anyway...
My Javascript is pretty horrible so possibly i introduced a bug, but the idea is that i want to have the javascript code insert the value of name into the javascript...
The javascript section gets huge so i want to use a pretty continuation section... like
| Code: |
js =
(
for (i = 0; x <>" HOW DO I INSERT NAME HERE?
... etc...
; i++){x=(document.getElementById('Table1').childNodes[1].childNodes[i].innerText); y+=(document.getElementById('Table1').childNodes[1].childNodes[i].childNodes[1].innerText)};", "y")...
... etc.
|
Maybe I should have posted this in tank's thread, but I think that this is more of a formatting question and not specific to the IE7 functions.
Any help would be extremely appreciated... things look a lot prettier when I can include them in a variable/continuation section and pass that, instead of the 300 or 500 characters on 1 line that I'll end up needing. |
|
| Back to top |
|
 |
CannedCheese
Joined: 21 May 2008 Posts: 85
|
Posted: Mon Aug 11, 2008 12:41 am Post subject: |
|
|
ug...
it occurs to me that I could do something like
| Code: |
js1 =
(
for (i = 0; x <> '
)
js2 =
(
'; i++){x=(document.getElementById('Table1').childNodes[1].childNodes[i].innerText); y+=(document.getElementById('Table1').childNodes[1].childNodes[i].childNodes[1].innerText)};"
)
|
and call it in a function as
| Code: |
IE7_ExecuteJS(myPageHandle, js1 . name . js2, "y")
|
Probably would work, but not as pretty... |
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 1145 Location: The Interwebs
|
Posted: Mon Aug 11, 2008 12:48 am Post subject: |
|
|
| Code: | js =
(
for (i = 0; x <>" %name%
; i++){x=(document.getElementById('Table1').childNodes[1].childNodes[i].innerText); y+=(document.getElementById('Table1').childNodes[1].childNodes[i].childNodes[1].innerText)};", "y")
)
IE7_ExecuteJS(myPageHandle, js, "y")
|
 |
|
| Back to top |
|
 |
CannedCheese
Joined: 21 May 2008 Posts: 85
|
Posted: Mon Aug 11, 2008 2:22 am Post subject: |
|
|
For some reason i figured that since it would handle semicolons as javascript and not as an AHK comment, I couldn't use ahk style variables. Probably a dumb assumption.
I think this will work. Thanks. |
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 1145 Location: The Interwebs
|
|
| Back to top |
|
 |
Jex
Joined: 01 Aug 2008 Posts: 61
|
Posted: Mon Aug 11, 2008 3:12 am Post subject: |
|
|
write the variable to a file...then have javascript read the file.
i know little on javascript... _________________ Woot.
Please read forum etiquette |
|
| Back to top |
|
 |
|