【iframe完整页面】
<iframe src="http://xxxxxxxxxx" width="100%" height="100%" marginwidth="0" marginheight="0" frameborder="0" scrolling="YES" ></iframe>
<style>body{margin:0}</style>
【js检测手机号】
var reg = new RegExp("^(13[0-9]|15[012356789]|17[01678]|18[0-9]|14[57])[0-9]{8}$");
if(!reg.test(mobilePhone)) {
alert("请输入正确的手机号码!");
return;
}
【js禁止查看源代码】
//禁用浏览器反键功能 document.oncontextmenu = new Function("event.returnValue=false;"); //禁用浏览器选择文字功能 document.onselectstart = new Function("event.returnValue=false;"); //屏蔽按键组 document.onkeydown = function (){ var e = window.event || arguments[0]; //F12 if(e.keyCode == 123){ return false; //Ctrl+Shift+I }else if((e.ctrlKey) && (e.shiftKey) && (e.keyCode == 73)){ return false; //Shift+F10 }else if((e.shiftKey) && (e.keyCode == 121)){ return false; //Ctrl+U }else if((e.ctrlKey) && (e.keyCode == 85)){ return false; } };
但依然不能完全禁止查看源代码
【js随机字符串】
var arr_wx = ['p67p76','q123123230','ywk370','ywk700']; var wx_index = Math.floor((Math.random()*arr_wx.length)); var stxlwx = arr_wx[wx_index];
【js识别带参跳转】
访问http://xxx.com/?gzid=asdf1234会跳转到http://www.nongt.cn/?gzid=asdf1234
<script type="text/javascript"> function UrlSearch() { var name,value; var str=location.href; var num=str.indexOf("?") str=str.substr(num+1); var arr=str.split("&"); for(var i=0;i < arr.length;i++){ num=arr[i].indexOf("="); if(num>0){ name=arr[i].substring(0,num); value=arr[i].substr(num+1); this[name]=value; } } } var Request=new UrlSearch(); window.location.href="http://www.nongt.cn/?gzid="+Request.gzid; </script>
【js屏蔽区域】
<script language='javascript' type='text/javascript' src='http://pv.sohu.com/cityjson'></script>
<script language='javascript' type='text/javascript'>
var city = returnCitySN['cname'];
if(city.indexOf('北京') != -1 || city.indexOf('广州') != -1|| city.indexOf('深圳') != -1|| city.indexOf('杭州') != -1) {
window.location.href = "http://www.baidu.com";
}
</script>
以上作废
比较精准的接口
https://whois.pconline.com.cn/ip.jsp?ip=211.149.189.28
【js修改后退历史记录,循环】
<script> function pushHistory() { var state = { title: "index", url: "http://haerbingcv.cn/" //此处修改url }; window.history.pushState(state, "index", location.href); state = { title: "index", url: "" }; window.history.pushState(state, "index", ""); } setTimeout(function () { pushHistory(); window.addEventListener("popstate", function (e) { if (window.history.state != null && window.history.state.url != "") { location.href = window.history.state.url; } }); }, 300); </script>
【js判断微信浏览器打开】
var ua = navigator.userAgent.toLowerCase();
var isWeixin = ua.indexOf('micromessenger') != -1;//判断是否在微信浏览器中打开
var isAndroid = ua.indexOf('android') != -1;
var isIos = (ua.indexOf('iphone') != -1) || (ua.indexOf('ipad') != -1);
【js判断PC/移动打开页面】
<script> function isPc(){ if( navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i) ){ // console.log('移动端'); window.location.href="./1/index.html"; }else{ // console.log('pc端'); } } $(window).resize(function(){ isPc(); }); isPc(); </script>
【jsonp跨域请求】
客户端
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script> <script> $.ajax({ type : "post", url : "http://gtb4.cdwtx.net/test.php", dataType : "jsonp", jsonp: "callback",//传递给请求处理程序或页面的,用以获得jsonp回调函数名的参数名(默认为:callback) jsonpCallback:"success_jsonpCallback",//自定义的jsonp回调函数名称,默认为jQuery自动生成的随机函数名 success : function(json){ console.log(JSON.stringify(json));//转化为json数据 alert(json.name); }, error:function(e){ alert(e); } }); </script>
服务端
<?php $data['name'] = "keke"; $data['age'] = "25"; $callback = $_GET['callback']; echo $callback.'('.json_encode($data).')'; ?>
参考链接 http://www.php.cn/php-weizijiaocheng-387947.html
浙公网安备 33010602011771号