js works in firefox but not ie

Discussion in 'HTML & Website Design' started by lektrikpuke, Sep 2, 2007.

  1. #1
    Hi y'all,

    The code works in firefox but doesn't seem to work in IE. Can anyone see the problem? Thanks.

    <script type="text/javascript">
    document.write("<table border=0 width=407 height=41>")
    document.write("<tr>")
    document.write("<td>")
    document.write("<p align=left>")
    document.write("<a href=")
    document.write(document.referrer)
    document.write(">")
    document.write("<font color=#686964 face=Trebuchet MS size=2>")
    document.write(document.referrer)
    document.write("</font></a></td></tr></table>")
    </script>
     
    lektrikpuke, Sep 2, 2007 IP
  2. tarponkeith

    tarponkeith Well-Known Member

    Messages:
    4,758
    Likes Received:
    279
    Best Answers:
    0
    Trophy Points:
    180
    #2
    Do you have it in the HEAD tags?

    I prefer to load javascript in the head tags, then only call them through a function when needed...

    Also, I'd recommend using semi-colons at the end of every line...

    I edited your code, the way that I would do it...

    <html>
    <head>
    <title>hi</title>
    
    <script type="text/javascript">
    <!--
    function showbacklink(){
    document.write("<a href='");
    document.write(document.referrer);
    document.write("'>Referrer</a>");
    }
    -->
    </script>
    
    </head>
    <body>
    
    <table border=0 width=407 height=41>
    <tr>
    <td>
    <p align=left>
    <font color=#686964 face=Trebuchet MS size=2>
    <script type="text/javascript">
    <!--
    showbacklink();
    -->
    </script>
    </font></a></td></tr></table>
    </body>
    </html>
    
    HTML:
    Tested it, and it works fine in IE and FF for me...
     
    tarponkeith, Sep 2, 2007 IP
  3. lektrikpuke

    lektrikpuke Well-Known Member

    Messages:
    297
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    113
    #3
    Thanks. It works on my server, too. Hopefully it'll work on my work's server (running MIVA).

    Thanks again. :D
     
    lektrikpuke, Sep 10, 2007 IP