Search code examples
javascriptjquerycsstumblr

how to detect a url path with jquery and change css


So I'm working on a Tumblr theme and i want the index (or home) page of the tumblr to display a div that I don't want the user to see on the following index pages.

For example, I want "myblog.tumblr.com" to have a big splash div with a tall height (let's call give this an id "homesplash"), while any pages under "myblog.tumblr.com/page/" to hide this div so the user can see the posts first. So like "myblog.tumblr.com/page/2", "myblog.tumblr.com/page/3", and so on.

How do I do this with jquery? How do I detect any url that contains "myblog.tumblr.com/page/" and hide that div? Appreciate any insight.


Solution

  • Not with jQuery per se, but you can just use window.location.pathname.

    if (window.location.pathname.indexOf('page') > 0) {
       $("#splash").hide();
    }