Help - Search - Members - Calendar
Full Version: Embedded HTML With XHTML Parsers
Pixel2Life Forum > Help Section > HTML, XHTML, CSS and General Web Design
worldnet
I've got some code I wrote in PHP that will generate a new argument
string for the browser, but the xhtml parser in Firefox and Opera both
complain about my use of &var=value pairs.

Below is my code that generates the string :

function InvokeURL(url_to_forward_to)
{
try
{
var xfamElem = document.getElementById('xFamily');
var mainform = document.getElementById('mainform');
var new_url = url_to_forward_to + "&variable=" + xfamElem.value;

mainform.action = new_url;
mainform.submit();
}
catch(error)
{
alert("InvokeURL encountered an error :" + error.description);
}
}

This works fine with *many* browsers except the new ones.. With IE on
windows (IE6) and Opera, Firefox all complain, Safari and some older
browsers seem to work OK..

If I change the line with the new_url variable setting on it to use a
& instead, it passes the XHTML tests but no longer works at all.. When
using the & it still has that in the URL that shows in the address
bar and hence it seems to cause the script on the other end a lot of
problems as it is unable to properly parse the URL string.

Any ideas on how to portably get around this problem with embedded &
created URL's?

Thank you,
Van
Wybe
just a quick little something, i don't remember running into this problem, could it have something to do with use of single quotes?

like
var new_url = url_to_forward_to + '&variable=' + xfamElem.value;

instead of
var new_url = url_to_forward_to + "&variable=" + xfamElem.value;

rc69
Try:
CODE
var new_url = url_to_forward_to + '\046variable=' + xfamElem.value;

Ideally it will avoid all problems by using the octal value of '&'. I've never tried it in the context you are using it, but it could work.

I'm not sure if JS distinguishes between quote types though.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.