SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jan 2005
    Location
    UK
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Differnent image shown depending on url

    Hi,

    I want to show an image if the url is http://www.sitename.com/page.php if the url is different I want to show another image.

    In my simple coding it would be

    If url = http://www.sitename.com/page.php
    show image 1
    else
    show image 2

    I would also like to be able to add some other pages with specific images using this method too, for example...

    If url = http://www.sitename.com/page.php
    show image 1
    If url = http://www.sitename.com/page2.php
    show image 2
    If url = http://www.sitename.com/page3.php
    show image 3
    else
    show image 4

    I have tried a few things to get this to work but so far have had no luck. Can anyone help me out? Please!

    TIA
    Simon

  2. #2
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Írebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I think that you should be able to do something like this:

    Code:
    if( document.URL == 'http://www.sitename.com/page.php' )
    {
      // display image 1
    }
    elseif( document.URL == 'http://www.sitename.com/page2.php' )
    {
      // display image 2
    }
    
    etc.
    Yours, Erik.
    ERIK RIKLUND :: Yes, I've been gone quite a while.

  3. #3
    SitePoint Member
    Join Date
    Jan 2005
    Location
    UK
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the code. I'm very new to Javascript and don't really understand where to put that and how to make it display the images. Would I use document.write?

    TIA
    Simon
    Last edited by recedo; Jan 9, 2005 at 16:34.

  4. #4
    SitePoint Member
    Join Date
    Jan 2005
    Location
    UK
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The nearest I could get to it was http://www.experts-exchange.com/Web/..._20707239.html

    can anyone suggest how I can adapt this to do what I want?

    Thanks
    Simon


Bookmarks

Posting Permissions

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