Go Premium for a chance to win a PS4. Enter to Win


read in parameter from URL

Posted on 2014-09-24
Medium Priority
Last Modified: 2014-09-25
I have a URL like this for example:

What I would like to capture is the integer before the '?' in jquery so I can then display different content based on the number.
So anything between the last / and the ?

Question by:Al4ddin2
LVL 58

Accepted Solution

Gary earned 2000 total points
ID: 40341672

myNumber= myUrl.pop();

Open in new window

LVL 82

Expert Comment

ID: 40341673
var url = location.href;
var int = url.match(/\/(\d*)\?/).pop() * 1;

checking :
alert( int);

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
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…
Suggested Courses

972 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