Forum Moderators: open
<a href='javascript:openit("/www.example.com/xx/xx/xx/index.php?id=0&print=1")' title="Print this page">Print</a>
Strangely, my browser returns & instead of & (and only for javascript() link?)
[edit]In fact, only FIrefox returns &, Opera and IE return a correct &?[/edit]
<a href='javascript:openit("/www.example.com/xx/xx/xx/index.php?id=0&print=1")' title="Print this page">Print</a>
For this reason, I am NOT W3C compliant.
Could someone explain what it only does it for javascript link and what I should do to returns a ampersand?
Thanks
[edited by: tedster at 6:52 pm (utc) on Dec. 6, 2004]
[edit reason] turn off graphic smilies [/edit]
The & should always be used for HTML, but never for anything else.
This adds confusion because:
1) Yes: document.writeln("<a href=...&...");
2) No: document.writeln("<a href=...&...");
Number one is correct becuase the line will be parsed by the HTML browser. Two is incorrect as it will be parsed through HTML.
3) No: <a href='javascript:openit("...&...")'>
4) Yes: <a href='javascript:openit("...&...")'>
This case is different. As the text supplied in going straight into the address bar and parsed and run by JavaScript, it will not be going through any HTML parsing and therefore & should NOT be used.
It is complicated to the point where validation tools can even get it wrong on occasion.
[edited by: tedster at 6:53 pm (utc) on Dec. 6, 2004]
[edit reason] turn off graphic smilies [/edit]
I am just wondering why HTML output in Firefox is different than output in IE/Opera.
If you're talking about when you view source in Firefox, the markup looks different because it shows some of Firefox's error correction rather than the straight original source code.
Here's a simple example to try:
<html><head>
<title></title>
</head>
<body
<p>text</p>
</body></html> Notice the missing > on the opening body tag. Open this file in Firefox, and view source. You'll see this:
<html><head>
<title></title>
</head>
<body
[b]>[/b]<p>text</p>
</body></html> The closing bracket for the body tag is added just before the opening
<p> - as Firefox corrects the error to be able to parse the rest of the page. If it didn't do this, the rest of the page might not show at all. IE and Opera do the same kind of correction, just that they don't show this in their view source option. For your original question, the validator is over-strict and maybe even wrong sometimes. Your page is valid, it just doesn't validate! I wouldn't worry about it.