read in parameter from URL

Posted on 2014-09-24
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 500 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
The viewer will learn how to dynamically set the form action using jQuery.
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)

786 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