function getUrlParam (name) {// packaging method var reg = new RegExp ( "( ^ | &)" + name + "= ([^ &] *) (& | $)"); // a structure containing the target parameter the regular expression object var r = window.location.search.substr (1) .match (reg); // parameter matches the target IF (! R & lt = null) return unescape (R & lt [2]); return null; // return value }
var code = getUrlParam ( 'code') // code path taken