Here is a basic browser URL
http://www.somegame.com/character.php?realm=MyRealm&name=MottyYou can extract out the realm or the name value using the script
Here is the modified code:var myStr = 'http://www.test.com/character.php?realm=MyRealm&name=Motty';
document.write ( gup('name', myStr) );
// outputs: Motty
document.write ( gup('realm', myStr) );
// outputs: MyRealm
function gup(n,s){
n = n.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");
var p = (new RegExp("[\\?&]"+n+"=([^&#]*)")).exec(s);
return (p===null) ? "" : p[1];
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.