& entity and the url

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply

Do you validate your pages for w3c compliance?

Yes
1
100%
No
0
No votes
What the heck is w3c!!!
0
No votes
 
Total votes: 1

webdevil
Beginner
Beginner
Posts: 4
Joined: Wed Apr 11, 2007 2:49 am

& entity and the url

Post by webdevil »

Ok... here is the dilemma.

my url : http://www.somewhere.com?v1=a&v2=b (not real of course)

I need to use "&" in my url... for the variable parameters etc.
If I use a normal '&' it works fine parameters pass etc.
But... w3c.org yells at me for having an &v2 that is not a valid entity.

So on to the entity itself... replace that pesky & with &
And of course i need the backticks (`) to insure the semi-colon doesnt mess up.

w3c validator loves me and I am fully XHTML compliant... but...
No go on passing the variables correctly. When I click that item it sends me to the page "http://www.somewhere.com?v1=a&v2=b"... basically the literal interpretation of the url, not the translated entity &.

This causes the variables after the & to fail to interpret by the parsing language (in my case php). So i know this is probably from some BS javascript limitation on the way it handles URLs, assignments, and redirects, but what can i do to use & in the url and maintain w3c valid XHTML. (i do not want the menu definition in its own js file, i need it embedded in the script tag as i have it)

This is only for the & entity as it is the only thing that the URL 'must' interpret correctly or you lose all your variables.

My idea was simply a .replace(/&/, '&') at the point where the URL is used by the menu builder. That way in the HTML output it can stay w3c friendly and the app can interpret it back to a normal '&' before use inside of itself. This would only have to be done on the URL parameter.

Anyone??? I am really really stuck... i need both w3c and '&'.
Uggggggggh.

Signed,
The Webdevil
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

Hi,

For starters, the W3C validator does not parse JavaScript so should be ignoring it.

Whatever you specify as the URL will be the URL so if you add a & it will be interpreted as that.

What you need to do is force the validator to not look at the JavaScript.

You should be able to do this by adding a CDATA clause to your script tags, like this:

Code: Select all

<script type="text/javascript"> 
// <![cdata[ 
_menuCloseDelay=500;
_menuOpenDelay=150;
_subOffsetTop=2;
_subOffsetLeft=-2;




with(menuStyle=new mm_style()){
bordercolor="#999999";
borderstyle="solid";
borderwidth=1;
fontfamily="Verdana, Tahoma, Arial";
fontsize="75%";
fontstyle="normal";
headerbgcolor="#ffffff";
headercolor="#000000";
offbgcolor="#eeeeee";
offcolor="#000000";
onbgcolor="#ddffdd";
oncolor="#000099";
outfilter="randomdissolve(duration=0.3)";
overfilter="Fade(duration=0.2);Alpha(opacity=90);Shadow(color=#777777', Direction=135, Strength=3)";
padding=4;
pagebgcolor="#82B6D7";
pagecolor="black";
separatorcolor="#999999";
separatorsize=1;
subimage="/menuimages/arrow.gif";
subimagepadding=2;
}

with(milonic=new menuname("Main Menu")){
alwaysvisible=1;
left=170;
orientation="horizontal";
style=menuStyle;
top=196;
aI("text=Home;url=http://milonic.com/;");
aI("showmenu=Samples;text=Menu Samples;");
aI("showmenu=Milonic;text=Milonic;");
aI("showmenu=Partners;text=Partners;");
aI("showmenu=Links;text=Links;");
aI("showmenu=MyMilonic;text=My Milonic;");
}

// ]]> 
</script> 
That should stop the validator from looking at your code.

HTH,
Andy
Post Reply