Archivio della categoria: javascript

Leggere le variabili GET in javascript

Snipplet per leggere le variabili GET in Javascript

function GET(q,s)
s = s ? s :;
var re = new RegExp('&'+q+'(?:=([^&]*))?(?=&|$)','i');
return (s=s.replace(/^\?/,'&').match(re)) ? (typeof s[1] == 'undefined' ? '' : decodeURIComponent(s[1])) : undefined;


var var1 = GET('v');


Ho trovato questa ottima funzione qui
Credits tuttavia andava fixata la regex, per questo la posto.

Get Root – Find iframe parent location

This function is useful to determinate information about the page who host an iframe from the iframe.

function get_root(obj, current_ref) {
if(obj.parent.location.href != current_ref) {
return get_root(obj.parent, obj.location.href);
else {
return obj.location.href;


get_root(window, window.location.href)

Credits to: 3xlstudio