witam
jestesmy na takiej stronie:
www.xxxxxxxx.pl/id=123456
i teraz w tresci tej strony chcialbym aby byl pobrany ten numer: 123456
bardzo prosze o pomoc jak to zrobic ? tylko nie w php...
z gory bardzo dziekuje za pomoc
I po wpisaniu przykładowo adresu http://jakasstrona.pl/id=12123123 zmienna liczba będzie zawierała 12123123.
function str_replace (search, replace, subject, count) { var i = 0, j = 0, temp = '', repl = '', sl = 0, fl = 0, f = [].concat(search), r = [].concat(replace), s = subject, ra = Object.prototype.toString.call(r) === '[object Array]', sa = Object.prototype.toString.call(s) === '[object Array]'; s = [].concat(s); if (count) { this.window[count] = 0; } for (i = 0, sl = s.length; i < sl; i++) { if (s[i] === '') { continue; } for (j = 0, fl = f.length; j < fl; j++) { temp = s[i] + ''; repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0]; s[i] = (temp).split(f[j]).join(repl); if (count && s[i] !== temp) { this.window[count] += (temp.length - s[i].length) / f[j].length; } } } return sa ? s : s[0]; } function strstr (haystack, needle, bool) { var pos = 0; haystack += ''; pos = haystack.indexOf(needle); if (pos == -1) { return false; } else { if (bool) { return haystack.substr(0, pos); } else { return haystack.slice(pos); } } } var liczba = strstr(location.href, "="); liczba = str_replace("=", "", liczba);
<body onload='document.getElementById("demo").innerHTML=window.location.href.toString().split("=")[1]'><span id=demo>