Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 6th, 2012  |  syntax: None  |  size: 0.55 KB  |  hits: 6  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Can jQuery detect a specific URL and perform a function based off that URL?
  2. <html>
  3. <head>
  4. <title>Title</title>
  5. <style type="text/css">
  6. .content {
  7. display: none;
  8. }
  9. .show {
  10. display: block;
  11. }
  12. </style>
  13. </head>
  14. <body>
  15. <div class="content">
  16. Lorem ipsum dolor sit amet, consectetur adipisicing elit.
  17. </div><!-- end .content -->
  18. </body>
  19. </html>
  20.        
  21. var url = "http://www.example.com/EIFS-items/search.php?l2=3,15,25";
  22. $(function(){
  23.   if (location.href==url){
  24.     $('.content').show();
  25.   }
  26. });
  27.        
  28. if(location.search == "?l2=3,15,25")
  29.     $('.content').addClass('show');