Solved

Tell if name in query string exists?

Posted on 2012-04-12
3
169 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
Comment Utility
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
Comment Utility
Why the > 0?
0
 
LVL 82

Expert Comment

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

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

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…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now