| | |
How to do an if statement based on url?
Please support our HTML and CSS advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2009
Posts: 1
Reputation:
Solved Threads: 0
Hi,
How can I make a message appear on my website if it's on a specif page of it? I din't write the source. It's HTML. Can I do an If or If While statement making the message appear only if the URL indicates the specific page of the website? You see, the person who did the site did not write comments on it and I'm not a super expert. The images on the site change, but all within a same frame. I will appreciate any help you can give me.
Thanks,
Lex
How can I make a message appear on my website if it's on a specif page of it? I din't write the source. It's HTML. Can I do an If or If While statement making the message appear only if the URL indicates the specific page of the website? You see, the person who did the site did not write comments on it and I'm not a super expert. The images on the site change, but all within a same frame. I will appreciate any help you can give me.
Thanks,
Lex
Here's a basic sample that you can start with:
HTML and CSS Syntax (Toggle Plain Text)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en"> <head> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Script-Type" content="text/javascript"> <meta http-equiv="Window-target" content="_top"> <title>Free Live Help!</title> <style type="text/css"> <!-- .normal { color : #909090; } .dynamic { color : #000; } --> /* ]]> */ </style> <script id="javascriptv15" type="text/javascript"> <!-- /******************************* - Provide all the URLs/Pages that you need inside this array collection. - This URLs/Pages will verify true/false coditions inside - your (if/else) blocks'. *******************************/ var $location = [ [ "http://www.somesite.com/", "test.html" ], [ '<font color="blue"> Message if <font color="red" size="1"><b>http://www.somesite.com/</b></font> is loaded</font>' , '<font color="blue">Message if <font color="red" size="1"><b>test</b></font><b>.</b>html is loaded</font>' ] ]; var message = function() { var myMsg = (( document.getElementById ) ? document.getElementById("msg") : document.all[ "msg" ] ); for ( var i = 0; i < $location[ 0 ].length; i++ ) { if ((( document.URL.indexOf( $location[ 0 ][ i ] )) || location.href.indexOf( $location[ 0 ][ i ] )) !== -1 ) { myMsg.className = "dynamic"; myMsg.innerHTML = "This is the current location :<br> " + $location[ 1 ][ i ]; return false; } } alert( "\n- File not found! -\nPlease make sure that your (x)HTML documents are properly defined inside the $location[ARRAY-OF-PAGES-COLLECTION]" ); } window.onload = message; // --> </script> </head> <body> <div id="main"> <span class="normal" id="msg"> Normal Text Content</span> </div> </body> </html>
![]() |
Similar Threads
- statement to open new url and close calling page. (PHP)
- PHP / SQL Delete From Statement Not working with URL? (PHP)
- url help (PHP)
- URL Rewrite, passing variables, or some other way??? (Linux Servers and Apache)
- Professional web-developer & architect for hire (Post your Resume)
Other Threads in the HTML and CSS Forum
- Previous Thread: div does not inherit correct width
- Next Thread: Help Indicator
| Thread Tools | Search this Thread |
appointments asp background backgroundcolor beta browser bug calendar cart cgi code codeinjection corporateidentity css design development displayimageinsteadofflash dreamweaver emailmarketing epilepsy explorer firefox flash form format google griefers hackers hitcounter hover html ide ie7 ie8 iframe image images internet internetexplorer intranet iphone javascript jpeg layout macbook maps marketshare microsoft mozilla multimedia navigationbars news offshoreoutsourcingcompany opacity opera optimization pnginie6 positioning problem scroll seo shopping studio swf swf. textcolor timecolor titletags url urlseparatedwords visual visualization web webdevelopment webform website windows7






