Why doesn't parser like this script?

K

KathyB

Hi, I'm using the following script to pass 3 variables to my next
form.

function Anomaly(typeIn,idIn,textIn)
{
var sType = 'type=' typeIn
var sIdNo = '&idNo=' idIn
var sText = '&text=' textIn

newWindow = window.open(('Anomaly.aspx?' + sType + sIdNo + sText),
'Anomaly', 'width=650')
}

My parser (msxml4) "thinks" there is a problem with variables sIdNo
and sText -- the &'s are causing it (expecting a semicolon after
'&idNo='). It functions but I don't want the user to see the browser
error...how else to I pass the multiple parameters?

Any thoughts?

Thanks, Kathy
 
M

Martin Honnen

KathyB said:
Hi, I'm using the following script to pass 3 variables to my next
form.

function Anomaly(typeIn,idIn,textIn)
{
var sType = 'type=' typeIn
var sIdNo = '&idNo=' idIn
var sText = '&text=' textIn

newWindow = window.open(('Anomaly.aspx?' + sType + sIdNo + sText),
'Anomaly', 'width=650')
}

My parser (msxml4) "thinks" there is a problem with variables sIdNo
and sText -- the &'s are causing it (expecting a semicolon after
'&idNo='). It functions but I don't want the user to see the browser
error...how else to I pass the multiple parameters?

Any thoughts?

MSXML 4 is an XML parser, if you are using it to parse HTML pages then
forget about that. If you are trying to author XHTML then you need to
follow XML rules where you would need to use
&
to escape an ampersand. However as you are probably trying to send XHTML
as text/html to HTML browsers you need another approach, one way is to
not use inline scripts but only external script files, another way is to use
<script type="text/javascript">
//<![CDATA[
script goes here
//]]>
</script>
that way your page is well-formed XML while being properly handled by
HTML browsers.
I (and others) however strongly suggest to use HTML 4.01 instead of
XHTML 1.0, see for instance
http://www.hixie.ch/advocacy/xhtml
 
S

Stuart Palmer

It _might_ be because you are missing + in your var calls.

var sType = 'type=' + typeIn;
var sIdNo = '&idNo=' + idIn;
var sText = '&text=' + textIn;

Best way to test is try:-

function Anomaly(typeIn,idIn,textIn)
{
var sType = 'type=' + typeIn;
var sIdNo = '&idNo=' + idIn;
var sText = '&text=' + textIn;
alert('Anomaly.aspx?' + sType + sIdNo + sText);
}

This will alert the total url line that is openeing in your popup window.

Stu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top