View Full Version : Newbie Help: JS displayed twice!

06-23-2009, 09:06 AM
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.

<script type="text/javascript">

Please help!

06-23-2009, 12:55 PM
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?

06-23-2009, 04:14 PM
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.

<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"></head><body>
<script type="text/javascript">

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?