View Full Version : check what url is it
d-machine
07-25-2008, 05:58 PM
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
rangana
07-26-2008, 01:48 AM
Hope this helps:
<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>
d-machine
07-26-2008, 02:18 AM
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.
thetestingsite
07-26-2008, 02:20 AM
You would place that code in place of this:
url='http://www.whatever.com'; // Set the address you want to compare
Hope this helps.
d-machine
07-26-2008, 02:26 AM
I'm sorry !! Other stuff in my code make the troubles.
Actually, it is working well !!
Thank you both !
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.