Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Two pages:

index.html/js
other_page.html/js


I need to get the ID value from my index.html in other_page using the url parâmeter...

What I have tried:

I have tried:

$.urlParam = function(name) {
            var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
            if (results == null) {
                return null;
            } else {
                return results[1] || 0;
            }
        }
var id_titulo_busca = $.urlParam('id_titulo');  //   
    if(id_titulo_busca !== 'null'){//  //carrega_descricao(id_titulo_busca);//alert(id_titulo_busca);//    }
  
  
$("pesquisar").click(function() {
    console.log( "ready!" );//    alert("test");
});
Posted
Updated 2-May-17 9:33am

1 solution

I types this in google:
Quote:
get url query param in javascript


I got a good response from here:
Get Query String Parameters with JavaScript[^]

It looks sound - I've used it myself before.

Pay special attention to the javascript fallback

I hope that you find this as useful as I have ^_^

Andy
 
Share this answer
 
Comments
MarkNopfler 2-May-17 15:56pm    
I think that maybe It not works using phonegap same..
Anyway thanks!
Andy Lanng 2-May-17 16:00pm    
Phonegaps was not in your question. No that probs wont work

But wait - even the JS fallback? It has the regex you need, doesn't it?
MarkNopfler 3-May-17 9:05am    
I don´t had inserted a plugin that wasn´t have in my other_page.html Now it works!
Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900