有用的JS函数

1. QueryString

function queryString(key) {

    var re = new RegExp("[?&]" + key + "=([^&$]*)", "i");

    var offset = window.location.search.search(re);

    if (offset == -1) return "";

    return RegExp.$1;

};

2. IFrame页面,返回父页面(如果A页面是IFrame内的页面,不想让其单独显示) 

   if (top && window == top) top.location = location.protocol + "//" + location.host;

 

你可能感兴趣的:(js)