View Full Version : document.write for a link in Safari ?

09-03-2011, 12:57 PM

Im testing the use of document.write and Im having trouble making a link work in Safari

document.write('<a href="index.htm"><img src="./images/portrait2.png"></a>');

This works in FF and IE9 but not in Safari (nor in Chrome), In Safari I see the portrait just fine but the cursor doesnt change when overing the image and clicking on it doesnt activate the link.
What is the correct way to write this line?

I have tried this and it also doesnt work in Safari and Chrome:

document.write("<a href='index.htm'><img src='./images/portrait2.png'></a>");

thanks for any insight

09-03-2011, 04:11 PM
Your code is correct. I tried it in Safari and it worked strieght off. I had to set chrome to allow javascript; it's turn off by default.

I placed the code inside of script tags in my header like this:

<script type="text/javascript">
document.write('<a href="test_1.html"><img src="./images/2.png"></a>');
I had to place my image and page in there, but it's the same code.

Check you JS setting in those browsers.