http://h3gsat.altervista.org/DettagliCompleto.php?id=4567
I tried to take the id
parameter, but I failed.
I have to make this work in javascript (jquery) not php, but I don't know how I can do.
http://h3gsat.altervista.org/DettagliCompleto.php?id=4567
I tried to take the id
parameter, but I failed.
I have to make this work in javascript (jquery) not php, but I don't know how I can do.
Try this code snippet:
$.urlParam = function(name){
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
return results[1] || 0;
}
// http://h3gsat.altervista.org/DettagliCompleto.php?id=4567
var value_of_id=$.urlParam('id'); // 6
console.log(value_of_id);
Here is demo jsFiddle
EDIT: Pure javascript solution
function urlParam(name){
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
return results[1] || 0;
}
// http://h3gsat.altervista.org/DettagliCompleto.php?id=4567
var value_of_id=urlParam('id'); // 6
console.log(value_of_id);
$(function(){
var str = $(location).attr('href');
alert(str);
var myString = str.substr(str.indexOf("?id=")+4);
alert(myString);
});