Paul Smith Paul Smith - 7 months ago 25
Javascript Question

div display:none when 'word' is in the url

Tried googling around and I can't seem to be able to find if this is even possible. I use IPBoard and due to their most recent IPS4 update i can no longer just change the homepage i have to add divs to global layout meaning they appear on every page, which aren’t what I’m wanting.

So i was wondering if it would be possible via

JavaScript
of
jquery
to hide the div when url contains a word.

Example div would appear on home 'domain.com/’, but not on 'domain/hidden/'
If this isn’t possible then let me know and I’ll remove it, I’m reasonably new to
JavaScript
and jquery I only really know html/css so please be patient.

Answer
if(window.location.href.indexOf("my-word") !== -1) {
    $("#my-div").hide()
}
Comments