简体   繁体   English

将HTML代码放入document.write

[英]Put HTML code inside document.write

I want to put this HTML inside document.write. 我想将此HTML放入document.write中。 How would I do that because the quotes get messed up when I try to. 我该怎么办,因为当我尝试时,引号变得混乱。

<a href="Home Page.html"
onMouseOver="document.thereg1.src=red1.src"
onMouseOut="document.thereg1.src=reg1.src">
<img src="1.gif" Name="thereg1"></a>

As the comment says you shouldn't really use document.write but if you have to you can do: 正如评论所说,您实际上不应该使用document.write但是如果需要的话,可以这样做:

document.write(
'<a href="Home Page.html"' +
'onMouseOver="document.thereg1.src=red1.src"' +
'onMouseOut="document.thereg1.src=reg1.src">' +
'<img src="1.gif" Name="thereg1"></a>'
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM