The reference states that the output() proc is able to call javascript functions using the format:
usr << output("[params]", "[element]:[function]")
When testing this in the default BYOND skin, it does function properly. When you create your own skin, however, it fails. I thought, perhaps, it was failing only in cloned browser elements, but it seems to fail no matter what, unless you use the default skin.
Numbered Steps to Reproduce Problem:
Create a new environment, paste the code below (from the ref example), and run. Use the newtext verb to replace the text in the browser.
You will see the expected result.
Now, create a new DMF interface file with a window containing a default browser element named browser. Run the program again. Use the newtext verb and notice the expected result fails to occur. The text is not changed.
Code Snippet (if applicable) to Reproduce Problem:
mob/Login()
. = ..()
usr << browse(" ")
usr << output(\
{"
<script type="text/javascript">
function replace(v) {
document.getElementById('foo').innerHTML =
v.replace(/&/g, '&').replace(/</g, '<');
}
</script>
<div id="foo">This text can change.</div>
<p>And this can't.</p>
"},
":browser");
#define LP(str) list2params(list(str))
mob/verb/newtext(T as text)
usr << output(LP(T), ":browser:replace")
Expected Results:
As the reference indicates, it is expected that the javascript function would be called in any browser element a user creates in their DMF interface file.
Actual Results:
The output() only functions properly for the default BYOND skin's browser element, and fails in any user-created browser elements.
Does the problem occur:
Every time? Or how often? Everytime
In other games? Yes
In other user accounts? Not sure
On other computers? Don't know.
When does the problem NOT occur?
If you only use the default BYOND skin, then the javascript function is called.
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.)
I presume this has been broken since 4.0, when interfaces were introduced.
Workarounds:
None.
In your head section.
This feature absolutely works, Eternia and SS13 both rely on it heavily, very heavily.
You're also making the rookie mistake of usr in Login(), but in this case it's not gonna make a difference; in a real hosted world though it absolutely can.