Vue打开新窗口被拦截
/** 解决浏览器拦截窗口,先打开空白窗口在乡该窗口的 location 中赋值 */let tempPage = window.open ("","_blank"); let routerUrl = this.$router.resolve ({ name:" 路由的 name", query:{" 查询参数 "} }) tempPage.location = r…
节流和防抖
防抖函数 当持续触发事件 一定时间内没有在触发事件 时间处理函数才会执行一次;如果设定的时间到来之前 有一次触发了事件 就重新开始延时。 // 利用闭包 function deounce (fun,delay){ let timer return function (args){ clearInterval (timer) timer = setTime…
监听滚动条距离底部的距离
window.addEventListener("scroll",function(){ console.log(document.documentElement.scrollTop); console.log(document.docucmentElement.scrollHeight); console.log(document.documen…
form表单提交跳页问题
html5 阻止 <html> <body> <form action=""method="post"target="nm_iframe"> <input type="text"id="id_input_text"name="nm_input_text"/> <input type="s…
.input点击效果
input:focus{ outline: none; border-style:solid; border-color: #03a9f4; box-shadow: 0 0 15px #03a9f4; }
URL相互转义
// 转义 /* http%3A%2F%2Fwww.baicu.com */encodeURLComponent ("http://www.baidu.com") // 逆转义 /* http://www.baidu.com */decodeURLComponent ("http%3A%2F%2Fwww.baicu.com")
将URL参数转成对象格式
function getQueryStringArgs (){ // 取得查询字符串并去掉开头的问号 var qs = (location.search.length> 0 ? location.search.substring (1) : ""), // 保存数据的对象 args = {}, // 取得每一项 items = qs.length ?…
监听浏览器是否安装插件
不兼容 IE function inspectPlugin (name){ name = name.toLowerCase (); for (var i=0;i<navigator.plugins.length;i++){ if (navigator.plugins [i].name.toLowerCase ().indexOf (name) >…
withCredentials
定义 withCredentials 属性是一个 Boolean 类型,它指示了是否该使用类似 cookies,authorization,headers (头部授权) 或者 TLS 客户端证书这一类资格证书来创建一个跨站点访问控制(cross-site Access-Control)请求。在同一个站点下使用 withCredentials 属性是无效的。此外,这个…
跨域问题CORS
同源 什么是同源协议 & 域名 & 端口号 都一直的情况才算同源查看源 window.origin 或 location.origin 可以查看当前当前源源协议 + 域名 + 端口号 同源策略 浏览器规定如果 JS 运行在源 A 里,就只能获得源 A 的数据,不能获得源 B 的数据,即不允许跨域 如何解决跨域 CORS 跨资源共享 javascript Acc…