Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

newbie: image.src

2 views
Skip to first unread message

Getho

unread,
May 12, 2005, 3:04:03 AM5/12/05
to
Hi I'm using the script below - works in firefox but not in IE. CAn anyone
help?

Getho

function readstring(){

var stringReceived = document.location.search;
// parse the string to get the value of the parameter
var avar = stringReceived.substring(stringReceived.indexOf("=")+1,
stringReceived.length);

re = /[?]/
codtal = avar.split(re)
//val = codtal[0]
tal = codtal[1]
document.image1.src = 'enlargements/'+tal
//alert ('enlargements/'+tal);
}


Getho

unread,
May 12, 2005, 3:10:04 AM5/12/05
to
I know why its not working at least: IE is taking codtal[0] to be the first
split. Huh?
Whats a better way of getting rid of the question mark?

Thanks
Geth

Getho

unread,
May 12, 2005, 6:33:26 AM5/12/05
to
Hey, I just figured out the index of thing, wahoo for me!

var stringReceived = document.location.search;
// parse the string to get the value of the parameter

var avar = stringReceived.substring(stringReceived.indexOf("?")+1,
stringReceived.length);
document.image1.src = 'enlargements/'+avar;

}

I gues this works so long as I have only one ? in the URL


Richard Cornford

unread,
May 12, 2005, 7:14:46 AM5/12/05
to
Getho wrote:
<snip>

> I gues this works so long as I have only one ? in the URL

If you have more than one '?' in a URL it is not a well-formed URL.
(That is; you are only allowed one '?' per URL.)

Richard.


RobG

unread,
May 12, 2005, 8:58:23 AM5/12/05
to

You could also use:

var avar = stringReceived.replace(/.*\?/,'');

'avar' will be all the characters after the '?'.

--
Rob

0 new messages