When passing certain strings as an argument to a JavaScript function, the method isn't being called at all. This seems to happen when the argument contains a newline character.
Code Snippet (if applicable) to Reproduce Problem:
mob/Login()
.=..()
usr << output(\
{"
<script type="text/javascript">
function replace(v) {
document.getElementById('foo').innerHTML = v;
}
</script>
<div id="foo">This text can change.</div>
<p>But this can't</p> "}, "browser1")
#define LP(str) list2params(list(str))
mob/verb/test()
var/T={"This is a test.
Line 2"}
usr << output(LP(T), "browser1:replace")
(Note: the script tag's < and > are being filtered out by the website.)
Expected Results:
'This text can change.' is replaced with the value of T.
Actual Results:
The replace() function is never even called.
Does the problem occur:
Every time? Or how often? Every time
In other games? Yes
On other computers? Not tested, but probably.
When does the problem NOT occur?
When the new line is removed from T's value.
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.)
Not sure.
Workarounds:
You could probably replace the newlines in a string with a different sequence of characters, pass it to JavaScript, and then replace that sequence with newlines from within the browser, but that isn't ideal.