Solved

Tell if name in query string exists?

Posted on 2012-04-12
3
173 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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…

809 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