美文网首页
js 兼容 hack

js 兼容 hack

作者: 蛋壳不讲武德 | 来源:发表于2020-05-09 17:59 被阅读0次

tips

window.location.protocol+"//"+window.location.host; 获取当前连接host  

err  http://10.0.20.23/wechat/js_sdk/ajaxWx?jsonpcallback=1&callback=jQuery331012469225729991806_1586917741798&url=http%253A%252F%252F10.0.20.23%252Fminvite%252F&_=1586917741799 获取了本地host  接口错误

err  Uncaught SyntaxError: Unexpected token '<'  请求接口 datatype :1-jsonp导致  2-“eval”函数是出错

tips

parseInt()和parseFloat()两个转换函数  只有对String类型调用这些方法,这两个函数才能正确运行;对其他类型返回的都是NaN(Not a Number)。

tips

document.body--窗口文档body  document.documentElement  窗口文档html   .scrollTop默认产生滚动条给到html||body,当子元素产生滚动条后 赋予子元素 window.pageYOffset
.offset().top 相对于文档  document.getElementsByClassName("b")[0].offsetTop相对于父元素第一个position不为static元素
document.documentElement.scrollHeight 计算元素 高度+滚动条高度body 100%  body>div设置overflow-x=hidden document.documentElement.scrollHeight为浏览器高度,div下子元素设置overflow-x=hidden; 则div内的子元素高度不计算在内

err Disable Unnecessary escape character: \/ no-useless-escape 1:禁用不必要的转义符:\ / no-useless-escape  可能 正则表达式未取到 验证对象导致的

err fatal: refusing to merge unrelated histories 合并提交 版本错位  可加参数 --allow-unrelated-histories 尝试

tips

在IE6中有另一个隐含的属性叫做hasLayout,该属性的作用和BFC类似,所以IE6浏览器可以通过开hasLayout来解决问题。开启方式有很多,但是副作用最小的方式是: 直接将元素的zoom设置为1即可

tips

clipbord 复制部分失败 尝试在复制按钮处添加 cursor:pointer; 无效可尝试添加点击事件
     $(".copywx").click(function () {alert("已复制微信,马上去添加好友");});

禁止触摸点击 touch-action: none;

#去除ifram的滚动条;
.inner-container {
            position: absolute; left: 0;
            overflow-x: hidden;
            overflow-y: scroll;
        }
        /* for Chrome 只针对谷歌浏览器*/
        .inner-container::-webkit-scrollbar {
            display: none;
        }

     <body class="inner-container">

.outer-container {
            position: relative;
            overflow: hidden;
        }

<body >
<div class="outer-container">
    <iframe  marginWidth=0 marginHeight=0 src="demo1.html"  scrolling="auto" frameBorder=0 width="100%"></iframe>
</div>
</body>

$(document).click() 在iphone上不触发事件解决办法

<div class="name">点我</div>
(document).on("click", ".name", function() { alert("name"); }); 以上代码在电脑浏览器和安卓上都能触发alert事件,但是在ios上却完全没有反应 查阅了很多信息后,说是iphone这些元素上没有click事件,它是touch事件, 就是说如果这个name标签是button的可click事件则是可以触发的,因为div本身默认不可点击 1、有一个解决方法是给这个元素添加css .name{ cursor:pointer; } 这样是可以解决的 2、但是如果你觉得粗暴的话,可以将click改为touchstart事件,或者共存(document).on(“click touchstart”, “.name”, function() {
alert(“name”);
});
复制/赋值时input弹出键盘 input.setAttribute('readonly', 'readonly');
const btn = document.querySelector('#btn');
btn.addEventListener('click',() => {
var input = document.createElement('input');
input.setAttribute('readonly', 'readonly');
input.setAttribute('value', 'hello world');
document.body.appendChild(input);
input.setSelectionRange(0, 9999);
if (document.execCommand('copy')) {
document.execCommand('copy');
console.log('复制成功');
}
document.body.removeChild(input);
})
2018/1/19添加
这个现在微信打开,安卓事件也是没有触发,上面2种方法依然适用,但是touchstart个人觉得滑动页面的时候会误触,还是喜欢用click + cursor

ios input button背景色不起作用的

input[type=button], input[type=submit], input[type=file], button { cursor: pointer; -webkit-appearance: none; }
background改成background-color

相关文章

  • js 兼容 hack

    tips tips tips tips tips

  • CSS Hack

    Hack是为解决浏览器样式兼容性而生。 链接:CSS Hack

  • css兼容(hack)

  • 浏览器兼容

    什么是 CSS hack CSS hack就是使你的CSS代码兼容不同的浏览器。CSS hack大致有3种表现形式...

  • 兼容 IE9 , IE10 ,IE11 Hack

    兼容 IE9 , IE10 ,IE11 Hack

  • Hack技术

    CSS Hack来解决浏览器局部的兼容性问题,hack主要针对IE浏览器常见的有三种形式:css属性Hack,cs...

  • CSS Hack技术

    Hacker:黑客CSS Hack:据此而来,通过浏览器解析漏洞从而衍生的兼容性调节技术 Hack概念 不同的浏览...

  • js hack

    Suppose you want the smallest number returned from Math.m...

  • bootstrap3 ie兼容

    1.这2个兼容js不被识别,然后莫名就被识别了,技术是不讲道理的 2.ie hack 2-1 不支持box-siz...

  • 浏览器兼容

    主要内容: CSS hack介绍、 浏览器兼容的思路、一些工具的介绍。 CSS hack 由于不同厂商的浏览器,...

网友评论

      本文标题:js 兼容 hack

      本文链接:https://www.haomeiwen.com/subject/xwclnhtx.html