Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Location
    Brighton, UK
    Posts
    282
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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>

  • #2
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    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.

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Location
    Brighton, UK
    Posts
    282
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •