Click to See Complete Forum and Search --> : Javascript help


Animal
05-04-2006, 03:00 PM
Hi All,

I'm having trouble with some javascript and browsers. I'm trying to use this code:

<script language="JavaScript" src="http://www.typefrag.com/status.aspx?sid=17174.876222321.14938"></script>

When I view it on Firefox it's in the correct location on the page, when viewed in IE or Netscape it shows at the bottom left of the page.( Looks like outside the body or main table. Should I have in the <head> tags or add more to the code above? Be beating my head on the desk!

Thanks in advance for any help!

A1ien51
05-04-2006, 04:23 PM
I would avoid using document.write

I would put a div/span before it and set the innerHTML of it.

Eric

phpnovice
05-04-2006, 09:41 PM
Also, when coding HTML in JavaScript string literals -- such as the following example:

document.write("</div>");

you need to escape certain characters. Thus, the above should be coded as follows:

document.write("<\/div>");

Charles
05-05-2006, 05:58 AM
Also, when coding HTML in JavaScript string literals -- such as the following example:

document.write("</div>");

you need to escape certain characters. Thus, the above should be coded as follows:

document.write("<\/div>");See http://www.w3.org/TR/REC-html40/appendix/notes.html#notes-specifying-data for details and note that this restriction only applies to scripts that occur in the middle of HTML. It doesn't apply to external scripts.

It also only applies to HTML. The restrictions for scripts in XHTML are much more severe.