ID:1896636
 
This is actually a javascript question, but I'm using the webclient so I think this can go here. :p

Code:
var
id = 0
_output

#define LP(str) list2params(list(str))

client
verb
say(t as text)
id++
_output = _output + {"<div id="chat[id]"><b><a class="rainbow">[src.ckey]:</b></a> [t]</div><br>"}
//src << output(_output, "browser")
//var/list/l = list("chat[id]","[_output]")
src << output(LP("chat[id]"), "browser:sel")
src << output(LP("[_output]"), "browser:edit")


/// THE SCRIPT, THIS IS IN _output before we add anything else.

<script>

var docu;

function sel(id){
docu = id;
};

function edit(v){
var d = document.getElementById(docu);
d.style.opacity = 0;
setTimeout(function(){d.innerHTML = v; d.style.opacity = 1;},500);
};

</script>


Problem description:
I can get the sel function to call, but edit does not alter the element im supposedly selecting. Any ideas?
I'd try spitting something out to console.log so you can see what's going on. IMO, I'd rather combine everything into a single call for simplicity.

// send two params instead of one, eliminating the need for sel()
src << output(list2params(list("chat[id]",_output)), "browser:edit")

Now at a guess, I suspect one possibility you may be seeing is if chat[id] is a skin element, maybe your id is including characters that will get mangled. The webclient will lowercase all IDs and it strips out most non-alphanumerics.

Of course if chat[id] is a skin element, then setting its innerHTML directly typically isn't a good idea; the element itself would just be the outer casing. Better would be something like this:

// assuming id is a skin element
function edit(id, v) {
// the byond() call will convert id to the correct form
byond(id).output({text: v});
}
Alright, sorry but I kept rolling after posting this and didn't see you reply. I now have a somewhat differant issue.

client

New()
src << output({"[css][content]"}, "browser")
winset(src, "input","command=say")
..()

verb
say(t as text)
id++
var/_output1 = {"<div id="chat[id]"><b><a class="blk_outline rainbow">[src.ckey]:</b></a> [t]</div>"}
world << output(list2params(list(_output1, "chat[id]")), "browser:edit")
//

world
New()
_output = css
..()

var
css = {"
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>


function edit(v, id){
var c = document.getElementById("chat_window")
var m = document.getElementById("chat" + id)

$(document).ready(function(){

$(c).append(v)
$(m).fadeIn("slow");

});
return false;
};

</script>


Here is the result. http://puu.sh/j0tMh/fcd9fff493.png

It looks like the second argument im sending is being received with the first argument of the JS function. browser is a skin control, but everything else is just pure html/css/js.
Something's odd here, because you're appending id to "chat" in edit() even though you already did so on the server end.

Here's the relevant code in browser.dms that handles output():

a = obj.text.replace(/<br\s*\/*>[\s\n\r]*$/i,'').split('&;');
// strip out BYOND formatting chars after unescape, in case they got included
for(i=a.length;i-->0;) a[i] = JSON.stringify(unescape(a[i].replace(/\+/g,' ')).replace(/\xff./g,''));
if(e && e.contentWindow) e.contentWindow.postMessage(sub+'('+a.join(',')+')', '*');

I can't rule out a webclient bug here, but I know I've tested JS a bit (especially for SS13) and it's worked before.