problem using javascript to get querystring

L

lion

my Problem:
a query string passed into a html page doesn't display correctly on a
mac
I am just using html and javascript (no ASP, PHP or server side
scripting)

This is the query string:
popup.html?pImage=30_leilani_dowding_b_060.jpg&ordRef=1000&Title=Leilani Dowding

using the QueryString function below, the pImage variable should be
equal to: 30_leilani_dowding_b_060.jpg
on a PC this is correct BUT on a mac it is displayed as:
'30_leilani_dowding_b_06030_leil'?

Has anyone experienced this problem?

cheers, lion

javascript to to display the image
<SCRIPT LANGUAGE="JavaScript">
document.write("<img src=images/wallpapers/"+pImage+" width='128'
height='128'>");
</script>

javascript function to get query string:
function QueryString(key)
{
var value = null;
for (var i=0;i<QueryString.keys.length;i++)
{
if (QueryString.keys==key)
{
value = QueryString.values;
break;
}
}
return value;
}
QueryString.keys = new Array();
QueryString.values = new Array();

function QueryString_Parse()
{
var query = window.location.search.substring(1);
var pairs = query.split("&");

for (var i=0;i<pairs.length;i++)
{
var pos = pairs.indexOf('=');
if (pos >= 0)
{
var argname = pairs.substring(0,pos);
var value = pairs.substring(pos+1);
QueryString.keys[QueryString.keys.length] = argname;
QueryString.values[QueryString.values.length] = value;
}
}

}

QueryString_Parse();

//set up the variables
//ordRef gets the order Number used i.e: 1000
var ordRef = QueryString("ordRef");
//
//Title gets the title passed e.g: Jordan&nbsp;Coldanski
var Title = QueryString("Title");
//
//pImage gets the image name including extension pImage=Jordan128.gif
var pImage = QueryString("pImage");
//
 
V

Vincent van Beveren

See the escape() and unescape() function. Use it to correctly encode
your query strings.

For example 'test.html?foo='+escape('big bar')
 

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,778
Messages
2,569,605
Members
45,237
Latest member
AvivMNS

Latest Threads

Top