我用 JavaScript 编写了这个(完整的代码)代码。
在第 6 行中,我编写了代码:
div_new = div_new+"<form name='"+name+"' onsubmit="+ return refresh(name, url, document.forms[name][name].value , '', '', 'refresh'); +" method='post' style='display:inline;'>";
当我添加此代码时,页面无法正常工作。
我相信我的引号有问题onsubmit
,因为当我删除“onsubmit”时,一切正常。
如果我用普通的 HTML(而不是 JS)编写完整的代码,一切都会很好。
我应该怎么做才能解决问题?
完整代码:
function chat(mem_id) {
count++;
var div_new = "<div style='position:absolute; width:200px; bottom:0px; left:10px;'>";
div_new = div_new+"<div style='width:100%; background-color:green;'>top "+ mem_id +" - "+count+"</div>";
div_new = div_new+"<div style='width:100%; height:300px; background-color:pink;'>bottom // refresh_chat"+ mem_id +" ";
var name = "send_chat_"+mem_id;
var url = "send_chat.php";
div_new = div_new+"<form name='"+name+"' onsubmit="+ return refresh(name, url, document.forms[name][name].value , '', '', 'refresh'); +" method='post' style='display:inline;'>";
div_new = div_new+"<textarea name='"+name+"' autofocus=autofocus placeholder='"+name+"'></textarea><input type=submit value=' send '>";
div_new = div_new+"</form>";
div_new = div_new+"</div>";
div_new = div_new+"</div>";
bottom = div_new;
document.getElementById('bottom').innerHTML = bottom;
}