PDA

View Full Version : alerting the code to call an image instead of the image value


chris_angell
03-10-2003, 04:00 PM
how come my document.card.src is not taking the value from the image in my page, that i know works but is coming up as text.. ie instead of saying... lg_photo/value.htm

it is saying "lg_photo/" + document.card.src + ".htm"

hmmmmm here is my code, I have tried with out the speach marks on htm and lg_photo.. and I get the same

function openIMG(){
window.alert('"lg_photo/" + document.card.src + ".htm"','mypop','width=500 , height=319','lg popups');
}


:rolleyes: hmmmmmmmm

Spudhead
03-10-2003, 04:08 PM
It's cos JS will use either single or double quotes as string identifers.

The JS sees alert( and then a single quote. The alert function in JS only has one parameter - the string to alert - so it assumes that its going to have to alert a string that's identified by single quotes. It looks for the next single quote, finds it after "htm" and ignores the rest of it because - lemme guess - you're using IE and IE is really forgiving of what it sees as code errors.

So - either strip the quotes out, escape them out, or build up a string variable to use then alert() that.

chris_angell
03-10-2003, 04:25 PM
woooo I think I get you... I have tried this

function openIMG(){
window.alert('lg_photo/ + document.card.src + .htm','mypop','width=500 , height=319','lg popups');
}


but nothing.. not to sure if you meant that.. I have also tried


var page = document.card.src

window.alert('lg_photo/ + page + .htm','mypop','width=500 , height=319','lg popups');
}

nothing.. what am I doing wrong