Rick wrote:
var new_url = url_to_forward_ to + "&variable= " + xfamElem.value;
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 you want to use an ampersand in XML you need to use the entity
reference & or you need to wrap your text into a CDATA section.
For script blocks in XHTML you can use e.g.
<script type="text/javascript">
//<![CDATA[
function InvokeURL(url_t o_forward_to)
{
try
{
var xfamElem = document.getEle mentById('xFami ly');
var mainform = document.getEle mentById('mainf orm');
var new_url = url_to_forward_ to + "&variable= " + xfamElem.value;
mainform.action = new_url;
mainform.submit ();
}
catch(error)
{
alert("InvokeUR L encountered an error :" + error.descripti on);
}
}
//]]>
</script>
to write your code in a way that is both compatible with HTML and XML
parsers.
If your only aim is to write X(HT)ML served to XML parsers then of course
<script type="text/javascript">
<![CDATA[
function InvokeURL(url_t o_forward_to)
{
try
{
var xfamElem = document.getEle mentById('xFami ly');
var mainform = document.getEle mentById('mainf orm');
var new_url = url_to_forward_ to + "&variable= " + xfamElem.value;
mainform.action = new_url;
mainform.submit ();
}
catch(error)
{
alert("InvokeUR L encountered an error :" + error.descripti on);
}
}
]]>
<script>
Or simply put your script code into an external .js file and include
that with
<script type="text/javascript" src="file.js"></script>
that way there will be no problems as the XML (or HTML) parser doesn't
see the script code at all.
--
Martin Honnen
http://JavaScript.FAQTs.com/