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 pull a field out of a string and return it. My
I'm trying to pull a large amount of data out of a WCF web
I am trying to pull out data from the table I had from the
im having some difficulty trying to pull out a specific value from a cookie.
i am trying to pull data from one table, compare columns to a variable,
I'm trying to pull all of the occurrences of a certain table out of
I'm currently trying to pull data from a database using a variable and then
I am trying to get wordpress to pull an ID from a variable to
I'm trying to pull data using a SqlDataReader, one column of which is in

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.