Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    document.write for a link in Safari ?

    Hello,

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


    Code:
    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:

    Code:
    document.write("<a href='index.htm'><img src='./images/portrait2.png'></a>");
    thanks for any insight

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,038
    Thanks
    23
    Thanked 589 Times in 588 Posts
    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:
    Code:
    <html>
    <head>
    <script type="text/javascript">
    document.write('<a href="test_1.html"><img src="./images/2.png"></a>');
    </script>
    </head>
    <body>
    I had to place my image and page in there, but it's the same code.

    Check you JS setting in those browsers.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •