I have the following script:

$(function () {
  var tabContainers = $('div.tabs > div');

  $(window).bind('hashchange', function () {
    var hash = window.location.hash || '[b][b]#[/b][/b]first';

    $('div.tabs ul.tabNavigation a').removeClass('selected');
    $('a[hash=' + hash + ']').addClass('selected');

  $(window).trigger( "hashchange" );

    <div class="tabs">
        <ul class="tabNavigation">
            <a href="#first" class="selected">First</a>
            <a href="#second" class="">Second</a>
            <a href="#third" class="">Third</a>
        <div id="first" style="display: block;">
        <div id="second" style="display: none;">
        <div id="third" style="display: none;">

How do i replace [b]#[/b] with [b]?[/b], so that it would be http://site.com/?first

Member Avatar for diafol

So you want to change the meaning of the uri from #fragment to query ?key, having no value?

I believe that ? will initiate a page reload. The #fragment is like a bookmark, so it doesn't go anywhere, unless you have an accompanying name anchor on the page.

Why do you need to do this?

Just to make it look better.
Also, is there a way to disable hash jumping?

Member Avatar for diafol

Just to make it look better.

That's what the ? character is for. The ? means 'start querystring from this point onwards'. You're happy for the page to refresh/reload when you press a link holding a href value with a '?' in it? If so, carry on.

ANyway, IMO, ? is an ugly character and many of us use mod rewriting to hide it! Well, OK, perhaps not the only reason to rewrite...

Also, is there a way to disable hash jumping?

WHat do you mean by that? Something like this?


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.