Emulating link actions with JavaScript
Dec 31, 2007 15:20:50 GMT -5
Post by turbov21 on Dec 31, 2007 15:20:50 GMT -5
I'm not sure if there's an automated way to do this, as I just started playing with it, but I've figured out how to submit data with an HTML button the same way you would with a LINK command.
submitFormTriggeringCallback is the JavaScript subroutine. I've got to dig into the internals a bit more, but I thought this proof of concept would pretty interesting.
x = 0
[start]
cls
titlebar "count: "+str$(x)
html "<h1>" + str$(x) + "</h1>"
link #link, "Add 1", [addone]
print ""
link #link, "Add 2", [addtwo]
print ""
html "<hr/>"
html "<input type=""button"" value=""Add 1"" onclick=""AddOne();""/>"
html "<script type=""text/javascript"">"
html "function AddOne() { "
html " var x = document.getElementsByTagName(""form"")[0].name;"
html " submitFormTriggeringCallback(x, '1', ""href"" );"
html " return false;"
html " }"
html "</script>"
wait
[addone]
x = x + 1
goto [start]
[addtwo]
x = x + 2
goto [start]
submitFormTriggeringCallback is the JavaScript subroutine. I've got to dig into the internals a bit more, but I thought this proof of concept would pretty interesting.