Results 1 to 2 of 2

Thread: If URL contains hashtag, then do this

  1. #1
    Join Date
    Oct 2011

    If URL contains hashtag, then do this

    If you go to thisiswhyimbroke.com and click any of the tabs, you'll see that an anchor/hash tag is added to each button. #a1,#a2, etc.

    I want to use a script where if the URL contains #a1, then it echos certain HTML/PHP.

    I was trying to use PHP for this but for some reason it can't detect anchors...

    Any help is appreciated!

  2. #2
    Join Date
    Oct 2011
    I actually got javascript to verify if there was a hashtag in the URL with this code:

    <script type="text/javascript">
                $(document).ready(function () {
                    if(window.location.href.indexOf("#a2") >= 0) 
                      //output specific HTML
    My only problem is I'm not sure how to outprint the HTML code I want there. I tried using a predefined PHP var, but to no success. Can anyone help me insert HTML with proper syntax? Here's the HTML for reference:

    <ul class="tabset">
    	<li class="active" id="tab1"><a href="#tab-1" class="tab">Random</a></li>
    	<li id="tab2"><a href="#tab-2" class="tab">Price High</a></li>
    	<li id="tab3"><a href="#tab-3" class="tab">Price Low</a></li>
    	<li id="tab4"><a href="#tab-5" class="tab">Food &amp; Drink</a></li>
    	<li id="tab5"><a href="#tab-6" class="tab">Home &amp; Office</a></li>
    	<li id="tab6"><a href="#tab-8" class="tab">Gadgets</a></li>
    	<li id="tab7"><a href="#tab-7" class="tab">Geek</a></li>
    	<li id="tab8"><a href="#tab-4" class="tab">Latest</a></li>
    	<li id="tab9"><a href="#tab-9" class="tab">All</a></li>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center