Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-10-2003, 04:00 PM   PM User | #1
chris_angell
Regular Coder

 
Join Date: Jul 2002
Location: Brighton, UK
Posts: 282
Thanks: 1
Thanked 0 Times in 0 Posts
chris_angell is an unknown quantity at this point
alerting the code to call an image instead of the image value

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


hmmmmmmmm
__________________
<marquee>thanks</marquee>
chris_angell is offline   Reply With Quote
Old 03-10-2003, 04:08 PM   PM User | #2
Spudhead
Senior Coder

 
Spudhead's Avatar
 
Join Date: Jun 2002
Location: London, UK
Posts: 1,856
Thanks: 8
Thanked 110 Times in 109 Posts
Spudhead is on a distinguished road
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.
Spudhead is offline   Reply With Quote
Old 03-10-2003, 04:25 PM   PM User | #3
chris_angell
Regular Coder

 
Join Date: Jul 2002
Location: Brighton, UK
Posts: 282
Thanks: 1
Thanked 0 Times in 0 Posts
chris_angell is an unknown quantity at this point
um..

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
__________________
<marquee>thanks</marquee>
chris_angell is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:17 PM.


Advertisement
Log in to turn off these ads.