...

View Full Version : URL bar



sherlockturtle
10-10-2011, 08:17 PM
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?

blaze4218
10-10-2011, 08:29 PM
You should search the forum. I answered that question just a couple weeks ago.

blaze4218
10-10-2011, 08:47 PM
This example was from http://www.codingforums.com/showthread.php?t=238766


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

sherlockturtle
10-11-2011, 01:52 AM
That did not work.

Logic Ali
10-11-2011, 02:16 AM
That did not work.

Maybe you should explain exactly what you're trying to do.

blaze4218
10-11-2011, 02:33 AM
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..

sherlockturtle
10-11-2011, 03:54 AM
I tried newest IE and google chrome. It didn't give me an error it just didn't do anything.

blaze4218
10-11-2011, 03:57 AM
Did u replace the pseudo code with real values?

sherlockturtle
10-11-2011, 04:03 AM
Did u replace the pseudo code with real values?

WHat part?

blaze4218
10-11-2011, 04:12 AM
The part that reffered to mysite and lib...

blaze4218
10-11-2011, 05:40 AM
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.

sherlockturtle
10-11-2011, 10:57 PM
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?

blaze4218
10-11-2011, 11:35 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum