Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript tabs like css-tricks snippet Reply To: tabs like css-tricks snippet

#265714
Shikkediel
Participant

I don’t think the page is redirected, Paulie:

function(s) {

  s.preventDefault();

  var e = $(this),
    t = e.find("a");

  if (snippetsTopNavLinks.removeClass("active"), t.addClass("active"), newClass = e.text(), listOfSnippets.removeClass(curClass).addClass(newClass), curClass = newClass, localStorage.setItem("snippetType", e.attr("id")), $(window).width() < 600) {
    var i = $("#list-of-snippets").position();
    window.scrollTo(0, i.top)
  }

  history.replaceState("", "", t.attr("href")), document.title = newClass + " | CSS-Tricks"
}

It prevents the default action of the link inside the li item and uses its href attribute to adapt the url without a page refresh…

Edit – please post any code you have, winc. Can’t debug a hypothetical. I doubt PHP or htaccess would be needed.