Emulating link actions with JavaScript

new BookmarkLockedFalling
turbov21
Guest

Guest Avatar

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.


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.
benjamin1
Full Member
***

benjamin1 Avatar

Posts: 117

[url]www.benjimenez.info[/url] [br]
turbov21
Guest

Guest Avatar

turbov21
Guest

Guest Avatar