How to do an if statement based on url?

Reply

Join Date: Jul 2009
Posts: 1
Reputation: Lex28 is an unknown quantity at this point 
Solved Threads: 0
Lex28 Lex28 is offline Offline
Newbie Poster

How to do an if statement based on url?

 
0
  #1
Jul 7th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 2,052
Reputation: serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light serkan sendur is a glorious beacon of light 
Solved Threads: 118
Featured Poster
serkan sendur serkan sendur is offline Offline
Postaholic

Re: How to do an if statement based on url?

 
0
  #2
Jul 7th, 2009
this can be done by javascript. you are going to create a div and put your message in it. then you are going to check the url of the webpage and change the display property of the div.style.
Due to lack of freedom of speech, i no longer post on this website.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 954
Reputation: essential will become famous soon enough essential will become famous soon enough 
Solved Threads: 131
Featured Poster
essential's Avatar
essential essential is offline Offline
Posting Shark

Re: How to do an if statement based on url?

 
0
  #3
Jul 9th, 2009
Here's a basic sample that you can start with:

HTML and CSS Syntax (Toggle Plain Text)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3. <html lang="en">
  4. <head>
  5. <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  7. <meta http-equiv="Content-Style-Type" content="text/css">
  8. <meta http-equiv="Content-Script-Type" content="text/javascript">
  9. <meta http-equiv="Window-target" content="_top">
  10. <title>Free Live Help!</title>
  11. <style type="text/css">
  12. <!--
  13. .normal { color : #909090; }
  14. .dynamic { color : #000; }
  15. -->
  16. /* ]]> */
  17. </style>
  18. <script id="javascriptv15" type="text/javascript">
  19. <!--
  20. /*******************************
  21.   - Provide all the URLs/Pages that
  22.   you need inside this
  23.   array collection.
  24.  
  25.   - This URLs/Pages will verify
  26.   true/false coditions inside -
  27.   your (if/else) blocks'.
  28. *******************************/
  29.  
  30. var $location = [ [ "http://www.somesite.com/", "test.html" ],
  31.  
  32. [ '<font color="blue">
  33. Message if <font color="red" size="1"><b>http://www.somesite.com/</b></font> is loaded</font>' ,
  34.  
  35. '<font color="blue">Message if <font color="red" size="1"><b>test</b></font><b>.</b>html is loaded</font>' ] ];
  36.  
  37.  
  38. var message = function() {
  39. var myMsg = (( document.getElementById ) ? document.getElementById("msg") : document.all[ "msg" ] );
  40. for ( var i = 0; i < $location[ 0 ].length; i++ ) {
  41. if ((( document.URL.indexOf( $location[ 0 ][ i ] )) || location.href.indexOf( $location[ 0 ][ i ] )) !== -1 ) {
  42. myMsg.className = "dynamic";
  43. myMsg.innerHTML = "This is the current location :<br> " + $location[ 1 ][ i ];
  44. return false;
  45. }
  46. } alert( "\n- File not found! -\nPlease make sure that your (x)HTML documents are properly defined inside the $location[ARRAY-OF-PAGES-COLLECTION]" );
  47. }
  48. window.onload = message;
  49.  
  50. // -->
  51. </script>
  52. </head>
  53. <body>
  54. <div id="main">
  55. <span class="normal" id="msg"> Normal Text Content</span>
  56. </div>
  57. </body>
  58. </html>
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC