0

Hi :) I'm a bit new to Javascript and Jquery in general, so I apologize if the question may seem confusing and whatnot.

I'm running a roleplaying forum (on the Jcink forum host), and I wanted some parts of the forum (which are technically "Out-of-Bounds" locations for members' characters, i.e., dangerous places in-character-wise) to display alerts whenever members access that particular part of the site.

I have tried to use

if(location.pathname == "[pathname here]") {
   alert("[message]"); 
}

in order to achieve this, although it does not seem to be working. Can anybody help me? :) Much thanks in advance!

  • I'd guess that whatever value you've used for `[pathname here]` is not matching what `location.pathname` is returning. It's impossible to tell from the small amount of code you've posted. Can you post some more detail? –  Jul 09 '13 at 01:52
  • 2
    Try putting just `alert(location.pathname)` on that page, and see what it displays. – Barmar Jul 09 '13 at 01:52
  • 1
    It's always a good idea to debug your code first. Something like console.log(location.pathname); or as mentioned above alert(); will point you in the right direction. There's no learning without fiddling, eventually you will figure stuff out yourself. But to be honest this is better done server side. – michaeltintiuc Jul 09 '13 at 01:56

0 Answers0