Forum Moderators: open

Message Too Old, No Replies

Simple Syntax Question

         

peterinwa

5:11 am on Mar 31, 2006 (gmt 0)

10+ Year Member



urlText=location+"a";
if (urlText.indexOf("abc")!=-1){
alert("URL contains abc")}

This works fine. I want the code to check to see if the current URL contains a certain text string so I can place ads on only certain pages.

But to make it work I had to add the:

+"a"

to make urlText a text string. As I say, it works fine but is there a better, simpler way?

Thanks, Peter Novice

DrDoc

5:25 am on Mar 31, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



use
location.href
instead of just
location

peterinwa

5:36 am on Mar 31, 2006 (gmt 0)

10+ Year Member



Thanks.