Page 1 of 1
& in url in JS rendering as not valid by W3C's validator
Posted: Fri Apr 01, 2005 12:21 pm
by anjanesh
In a JS code embedded in an HTML page.
Code: Select all
document.getElementById("e;frm1"e;).action = "e;somepage.php?x=1&y=2"e;;
W3C' validator is showing errors because of the & sign in the url.
1. Why is it
trying to validate code in JS block ?
2. When I replace & with & it shows This Page Is Valid etc etc but obviously the url sent to is somepage.php?x=1
&y=2 and not somepage.php?x=1&y=2.
How I rectify this ?
Thanks
Posted: Fri Apr 01, 2005 12:35 pm
by feyd
that is correct usage in XHTML, at least.. The browser should parse it as you think it should.
Posted: Fri Apr 01, 2005 12:42 pm
by anjanesh
But it doesnt seem to work with & - W3C is parsing it as valid though.
But when the form is submitted the url has & instead of &
Code: Select all
<script type="e;text/javascript"e;>
function somefunction ()
{
// determine what y's value is
document.getElementById("e;frm1"e;).action = "e;somepage.php?x=1&y="e;+y;
document.getElementById("e;frm1"e;).submit();
}
</script>
y is not user-input - some value based on what the user does on the page
Re: & in url in JS rendering as not valid by W3C's valid
Posted: Fri Apr 01, 2005 1:05 pm
by Roja
anjanesh wrote:
1. Why is it trying to validating code in JS block ?
Boy: Do not try and bend the spoon. That's impossible. Instead only try to realize the truth.
Neo: What truth?
Boy: There is no spoon.
Neo: There is no spoon?
Boy: Then you'll see that it is not the spoon that bends, it is only yourself.
--
Solution: Move your js to a seperate file, as you should anyways, so it can be cached. Then there will be no spoon for the validator to try and bend.
Posted: Sat Apr 02, 2005 10:43 am
by Chris Corbyn
Just a guess but correctly commenting out your code might help.
You should be doing this anyway.
Code: Select all
<script type="e;text/javascript"e;>
<!-- Comment me out
// End -->
</script>
Re: & in url in JS rendering as not valid by W3C's valid
Posted: Mon Apr 04, 2005 3:30 am
by n00b Saibot
<off-topic>
Roja wrote:
Boy: Do not try and bend the spoon. That's impossible. Instead only try to realize the truth.
Neo: What truth?
Boy: There is no spoon.
Neo: There is no spoon?
Boy: Then you'll see that it is not the spoon that bends, it is only yourself.
You sure seem to be as impressed by
The MATRIX as I am. Truly stumped
