Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6606849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:26:22+00:00 2026-05-25T19:26:22+00:00

I am trying to pull the variable cid out of the querystring in JQuery

  • 0

I am trying to pull the variable cid out of the querystring in JQuery Mobile beta 3.

Example of Normal URL would be
/category.php?cid=23

Example of JQuery Mobile URL
/#/category.php?cid=23

I can pull the variable out of the querystring normally with the function below in most browsers, because of JQuery Mobile Beta 3’s url rewriting. However IE does not support the new browser history functions. https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history

Therefore I need a way to pull out the querystring from JQuery Mobile Url seen above and the following function I normally use below does not work properly for that.

function getQuerystring(key) {
   var re=new RegExp('(?:\\?|&)'+key+'=(.*?)(?=&|$)','gi');
   var r=[], m;
   while ((m=re.exec(document.location.search)) != null) r.push(m[1]);
   return r;
}

I am either looking for an alternative regex that could find the hashed variable in browsers that don’t support history.pushState or some other solution entirely. I’ve searched in the documentation for a solution to this problem, but haven’t found anything. I would think this would be a problem that would have been thought out and solved already by the JQuery Mobile Team, I am probably just missing something pretty obvious. Thanks in advance for any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:26:23+00:00Added an answer on May 25, 2026 at 7:26 pm

    Okay here is a function that will take care of both situations no matter what browser you are on or even what way you are using JQuery Mobile. This code isn’t perfect, I’m just happy it works at the moment. If and when I update the function I’ll come back and update it here.

    First the code looks to see if there is a hash. If there is it looks for a querystring in it just as if it was a url. If not it simply checks the url for the variable. This code works with checking a particular querystring variable no matter what state your checking it in JQuery Mobile. Weather it’s pagecreate pageshow or in just about any other event, weather JQuery Mobile Beta 3 has rewritten the url via pushstate or not.

    function getQuerystring(name) {
        var hash = document.location.hash;
        var match = "";
        if (hash != undefined && hash != null && hash != '') {
            match = RegExp('[?&]' + name + '=([^&]*)').exec(hash);
        }
        else {
            match = RegExp('[?&]' + name + '=([^&]*)').exec(document.location.search);
        }
        return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to pull a variable out of a URL or get an empty
I am trying come up with a way to pull the tables out of
I would like to pull artifacts from teamcity. I've been trying to use c#
I am trying to get jquery to pick up variable that I am defining
I've generated some JSON and I'm trying to pull it into an object in
I'm trying to make a pull down menu post a form when the user
I'm trying to use SharpZipLib to pull specified files from a zip archive. All
I'm trying to write a query that will pull back the two most recent
I am trying to write a function that will pull the name of a
Using SQLite3 with Python 2.5, I'm trying to iterate through a list and pull

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.