Results 1 to 5 of 5

Thread: check what url is it

  1. #1
    Join Date
    Nov 2007
    Posts
    151
    Thanks
    67
    Thanked 0 Times in 0 Posts

    Default check what url is it

    I want to write a Switch statement that will check the url of the page and if the URL is: http://www.blabla.com/?page_id=4
    than it'll write: "this is a nice page"

    and if it the adress is: http://www.blabla.com/?page_id=4
    than it'll write: "I love this page"

    thanks
    Last edited by d-machine; 07-25-2008 at 06:09 PM.

  2. #2
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    Hope this helps:
    Code:
    <script type="text/javascript">
    window.onload=function(){
    var nicepage='http://www.dynamicdrive.com', //  Set the address of the page you think is nice
    lovepage='http://www.google.com', // Set the address of the page you think you love
    url='http://www.whatever.com'; // Set the address you want to compare
    	switch(url){
    	case nicepage:alert('This is a nice page.');break;
    	case lovepage:alert('I love this page.');break;
    	default: alert('I neither love nor find this page nice.');
    	}
    }
    </script>
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  3. The Following User Says Thank You to rangana For This Useful Post:

    d-machine (07-26-2008)

  4. #3
    Join Date
    Nov 2007
    Posts
    151
    Thanks
    67
    Thanked 0 Times in 0 Posts

    Default

    Thank you but I think there should be use of this:

    window.document.location.href

    I just don't know where to put it

    In this way, this code is not working.

  5. #4
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    You would place that code in place of this:

    Code:
    url='http://www.whatever.com'; // Set the address you want to compare
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  6. The Following User Says Thank You to thetestingsite For This Useful Post:

    d-machine (07-26-2008)

  7. #5
    Join Date
    Nov 2007
    Posts
    151
    Thanks
    67
    Thanked 0 Times in 0 Posts

    Default

    I'm sorry !! Other stuff in my code make the troubles.

    Actually, it is working well !!

    Thank you both !

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
  •