0

I want to put this HTML inside 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>
asked Nov 6, 2013 at 1:15
2
  • The escape character for javascript is \ so you need to escape your quotes like so "<a href=\"Home Page.html\" .... </a>" Commented Nov 6, 2013 at 1:17
  • ...and your questions is probably being downvoted because you shouldn't be using document.write to create html content. Instead look at creating a new node and setting the html content of that instead Commented Nov 6, 2013 at 1:21

1 Answer 1

1

As the comment says you shouldn't really use document.write but if you have to you can do:

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>'
);
answered Nov 6, 2013 at 1:48
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.