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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Newbie Help: JS displayed twice!

    Hello everyone!

    I have a problem when trying to insert some Javascript into my HTML document.

    Normally, everything appears as it should. But when I open the page in Firefox, use "File -> Save Page As..." to save the document with another name, then open up the copy, all the Javascript appears twice!

    It looks like Firefox is including the new content from document.write() along with the original script. I've tried it in IE and it does not appear to happen. I'm very new to JS, so is this a problem with my technique or what? Is there any way to avoid this?

    Here's some sample code to reproduce the problem. Save as .html file.

    Code:
    <html><body>
    <script type="text/javascript">
    <!--
    document.write("hello");
    //-->
    </script>
    </body></html>
    Please help!

  • #2
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    I can't reproduce this.

    To clarify:

    1. Copy code above into blank document.
    2. Save as "test.html"
    3. Open "test.html" in FF
    4. File -> Save Page As -> "test2.html"
    5. Open "test2.html" in FF
    6. View source

    The code appears exactly as it does above.

    Are you doing something different?

  • #3
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No, that's exactly what I'm doing. However, for me, the new source for "test2.html" appears as this, with another "hello" appearing after the script.

    Code:
    <html><head>
    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"></head><body>
    <script type="text/javascript">
    <!--
    document.write("hello");
    //-->
    </script>hello
    </body></html>
    I've noticed that "save page as" works as expected when accessed from the page source view, but it results in the content above when viewing it normally in a tab. Could this just be Firefox's normal behavior? Am I doing something wrong?


  •  

    Posting Permissions

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