views:

40

answers:

3

If two url are like:

http://localhost:1113/Project/TestCourse.aspx?id=

http://localhost:1112/Project/TestCourse.aspx

How to check whether 'id' is present or not using javascript?

+1  A: 

How about:

location.href.match(/\?id\=|&id\=/i)
KooiInc
A: 

use location.href.match(/\?id\=/i) && location.href.match(/&id\=/i)

Bang Dao
KooiInc
A: 

hi, this may help you: http://stackoverflow.com/questions/3183830/how-to-get-the-querystring-with-javascript-and-if-there-is-no-querystring

Alex Pacurar
Seems to me that answer is way to complex for such a simple problem, really.
KooiInc