Solved

Tell if name in query string exists?

Posted on 2012-04-12
3
171 Views
Last Modified: 2012-04-12
If i have a URL like below

http://mySite.com/store/en_US/pd/productID.225126100/sac.true?gaikaiInstantPlay

what is the best way to determine if "gaikaiInstantPlay" is in the URL?

Thanks!
0
Comment
Question by:894359
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 37840481
var gaikaiInstantPlay_is_in_the_URL =  location.href.indexOf("gaikaiInstantPlay") > 0; // this is true or false

if( gaikaiInstantPlay_is_in_the_URL ) alert("ok");
else alert("not in the URL");

Open in new window

0
 

Author Comment

by:894359
ID: 37840495
Why the > 0?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 37840496
indexOf return -1 if the string is not found : http://www.w3schools.com/jsref/jsref_indexof.asp
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

775 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question