newbie: image.src

G

Getho

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);
}
 
G

Getho

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
 
G

Getho

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
 
R

Richard Cornford

Getho wrote:
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.
 
R

RobG

Getho said:
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

You could also use:

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

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

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,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top