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 13 of 13

Thread: URL bar

  1. #1
    Regular Coder
    Join Date
    May 2011
    Posts
    357
    Thanks
    23
    Thanked 1 Time in 1 Post

    URL bar

    Is there a way to check what the URL bar is = to? so if it was equal to www.codingforums.com it would change something on the page?

  • #2
    Regular Coder
    Join Date
    Apr 2005
    Location
    Texas
    Posts
    448
    Thanks
    24
    Thanked 63 Times in 63 Posts
    You should search the forum. I answered that question just a couple weeks ago.

  • #3
    Regular Coder
    Join Date
    Apr 2005
    Location
    Texas
    Posts
    448
    Thanks
    24
    Thanked 63 Times in 63 Posts
    This example was from http://www.codingforums.com/showthread.php?t=238766
    Quote Originally Posted by blaze4218 View Post
    Code:
    <div id="someThing" style="display:block" >Put something here.</div>
    
    <script type="text/javascript">
    // tested URL was www.mysite.com/lib/test.html
    var nowUrl = location.href;
    if (nowUrl.match('lib')) { // testing the url for a match on "lib"
     document.getElementById("someThing").innerHTML = 'Found it!';	// this worked
     }
    else{
     document.getElementById("someThing").innerHTML = 'Not There...';	
     }
    </script>

  • #4
    Regular Coder
    Join Date
    May 2011
    Posts
    357
    Thanks
    23
    Thanked 1 Time in 1 Post
    That did not work.

  • #5
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Location
    London
    Posts
    1,028
    Thanks
    0
    Thanked 207 Times in 202 Posts
    Quote Originally Posted by sherlockturtle View Post
    That did not work.
    Maybe you should explain exactly what you're trying to do.

  • #6
    Regular Coder
    Join Date
    Apr 2005
    Location
    Texas
    Posts
    448
    Thanks
    24
    Thanked 63 Times in 63 Posts
    Well it worked two weeks ago... Maybe it's gone sour. I'll whip up a fresh batch.
    Meanwhile, maybe you'd like to tell me why it didn't work (gave you an error?) and what browser your using..

  • #7
    Regular Coder
    Join Date
    May 2011
    Posts
    357
    Thanks
    23
    Thanked 1 Time in 1 Post
    I tried newest IE and google chrome. It didn't give me an error it just didn't do anything.

  • #8
    Regular Coder
    Join Date
    Apr 2005
    Location
    Texas
    Posts
    448
    Thanks
    24
    Thanked 63 Times in 63 Posts
    Did u replace the pseudo code with real values?

  • #9
    Regular Coder
    Join Date
    May 2011
    Posts
    357
    Thanks
    23
    Thanked 1 Time in 1 Post
    Quote Originally Posted by blaze4218 View Post
    Did u replace the pseudo code with real values?
    WHat part?
    Last edited by sherlockturtle; 10-11-2011 at 04:06 AM.

  • #10
    Regular Coder
    Join Date
    Apr 2005
    Location
    Texas
    Posts
    448
    Thanks
    24
    Thanked 63 Times in 63 Posts
    The part that reffered to mysite and lib...

  • #11
    Regular Coder
    Join Date
    Apr 2005
    Location
    Texas
    Posts
    448
    Thanks
    24
    Thanked 63 Times in 63 Posts
    Buddy, I'm trying to help you but your not making it easy. I've asked you in several of your threads to provide more info, or show some kind of code indicating where you are, but getting anything back is like pulling teeth. I tested that code in the latest IE, Chrome, and Firefox... Even my iPhone! It works... If you couldn't get it to work you did something wrong, so if you would like to show me your actual code I will try to help you fix your error. If you can't for any reason, then there isn't much more I can do. Sorry.

  • #12
    Regular Coder
    Join Date
    May 2011
    Posts
    357
    Thanks
    23
    Thanked 1 Time in 1 Post
    Quote Originally Posted by blaze4218 View Post
    The part that reffered to mysite and lib...
    You meenthe var nowURL? What do i change them to? and lib does that have to change?

  • #13
    Regular Coder
    Join Date
    Apr 2005
    Location
    Texas
    Posts
    448
    Thanks
    24
    Thanked 63 Times in 63 Posts
    Actually I posted that from my cell phone, I was reading the code on a very small screen, and shouldn't have said the 'mysite.com' bit. The part you need to change is the 'lib'. And as far what you need to change it to: Change it to whatever value you are testing for. But that doesn't change the fact that you say it "didn't do anything". It should've done something no matter what. Please explain yourself better. And please post the section of code you say doesn't work. I'm not psychic.


  •  

    Posting Permissions

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