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>
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>'
);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.