Calling/sending params to a javascript function via output() does not work... see the code snippet + output entry for more information.
Numbered Steps to Reproduce Problem:
Tried using the snippet in the DM reference with no results
Code Snippet (if applicable) to Reproduce Problem:
Click()
winset(usr, "child", "left=browin") // browin contains the browser element named 'browser'
usr << output(\
{"
<script type="text/javascript">
function replace(v) {
document.getElementById('foo').innerHTML = v;
}
</script>
<div id="foo">This text can change.</div>
<p>And this can't.</p>
"},
"browser");
usr << output("'Hi'","browser:replace")
Expected Results:
"This text can change" to be changed into "'Hi'".
Actual Results:
No changes happen at all.
Does the problem occur:
Every time? Or how often?
Everytime. N/A for the other questions.
Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
Did not try yet.
However because this is a timing issue, it should be easy enough to resolve with a sleep(). If you put a short sleep() in between sending the page to the browser and calling the function, the issue will go away. I tested with a 1-second delay and had no problem, but you could probably get away with an even shorter timeout. I recommend that as a workaround. Another possible workaround is to simply include the text you want to be there when you send the original document to the browser, and only use JS for later updates.