setTimeout 变量作用域链查找 var a=1; setTimeout(function(){ alert(window.a); //2 alert(a); // alert undefined 首先在匿名函数作用域中查找搜索,后面有声明 var a ,在声明之前调用自然就是undefined var a=3; },1000); a=2;
setTimeout 变量作用域链查找 var a=1; setTimeout(function(){ alert(window.a); //2 alert(a); // alert undefined 首先在匿名函数作用域中查找搜索,后面有声明 var a ,在声明之前调用自然就是undefined var a=3; },1000); a=2;
原生js: window.onload=function(){ var topframe=document.getElementById(“ifr”); var ifrDoc=topframe.contentDocument|| topframe.contentWindow.document; topframe.style.height=Math.max(ifrDoc.documentElement.scrollHeight,ifrDoc.documentElement.clientHeight)+”px”; }
jq:
$(window).load(function(){ var topframe=$(“#ifr”); var ifrDoc=$(“#ifr”).contents(); topframe.height(ifrDoc.height()); })
原生js: window.onload=function(){ var topframe=document.getElementById(“ifr”); var ifrDoc=topframe.contentDocument|| topframe.contentWindow.document; topframe.style.height=Math.max(ifrDoc.documentElement.scrollHeight,ifrDoc.documentElement.clientHeight)+”px”; }
jq:
$(window).load(function(){ var topframe=$(“#ifr”); var ifrDoc=$(“#ifr”).contents(); topframe.height(ifrDoc.height()); })
https://www.cnblogs.com/dolphinX/p/3348458.html
代码:
<style>
*{margin: 0;padding: 0;}
.box{width: 400px;height: 500px;border: 1px solid #f00;text-align: center;display: table;position: relative;}
.box span{display: table-cell;vertical-align: middle;*position: absolute;*left: 50%;*top: 50%;}
.box img{background-color: #f00;*position: relative;*left: -50%;*top: -50%;}
</style>
<div class=”box”>
<span><img src=”#” alt=”” width=”200″ height=”100″></span>
</div>
不定高度图片垂直居中兼容写法,ie7以下的浏览器还是 很恶心的说….
第2行
作业薄css3实现代码:
<div class=”lines”>第1行 <br/>第2行</div>
<style>
.lines{width: 200px;height: 209px;padding: 0 5px;line-height: 30px;
background:-webkit-linear-gradient(#f9f9f9 29px, #ccc 30px);
background:-o-linear-gradient(#f9f9f9 29px, #ccc 30px);
background:linear-gradient(#f9f9f9 29px, #ccc 30px);
background-size: 100% 30px;
background-attachment: local;
}
</style>
实现思路解析:
linear-gradient实现单行线效果,但要整个容器行线平铺,要用background-size,将linear-gradient定义的背景图定义成30px高的背景图片,这样才有平铺效果出来!
代码:
<style>
*{margin: 0;padding: 0;}
.box{width: 400px;height: 500px;border: 1px solid #f00;text-align: center;display: table;position: relative;}
.box span{display: table-cell;vertical-align: middle;*position: absolute;*left: 50%;*top: 50%;}
.box img{background-color: #f00;*position: relative;*left: -50%;*top: -50%;}
</style>
<div class=”box”>
<span><img src=”#” alt=”” width=”200″ height=”100″></span>
</div>
不定高度图片垂直居中兼容写法,ie7以下的浏览器还是 很恶心的说….
第2行
作业薄css3实现代码:
<div class=”lines”>第1行 <br/>第2行</div>
<style>
.lines{width: 200px;height: 209px;padding: 0 5px;line-height: 30px;
background:-webkit-linear-gradient(#f9f9f9 29px, #ccc 30px);
background:-o-linear-gradient(#f9f9f9 29px, #ccc 30px);
background:linear-gradient(#f9f9f9 29px, #ccc 30px);
background-size: 100% 30px;
background-attachment: local;
}
</style>
实现思路解析:
linear-gradient实现单行线效果,但要整个容器行线平铺,要用background-size,将linear-gradient定义的背景图定义成30px高的背景图片,这样才有平铺效果出来!
var a=1;
setTimeout(function(){
alert(window.a); //2
alert(a); // alert undefined 首先在匿名函数作用域中查找搜索,后面有声明 var a ,在声明之前调用自然就是undefined
var a=3;
},1000);
a=2;
var a=1;
setTimeout(function(){
alert(window.a); //2
alert(a); // alert undefined 首先在匿名函数作用域中查找搜索,后面有声明 var a ,在声明之前调用自然就是undefined
var a=3;
},1000);
a=2;
非跨域:
<iframe src=”https://www.test.org/myiframe.html” frameborder=”0″ width=”100%” id=”ifr” height=”100%” marginwidth=”0″ marginheight=”0″></iframe>
原生js:
window.onload=function(){
var topframe=document.getElementById(“ifr”);
var ifrDoc=topframe.contentDocument|| topframe.contentWindow.document;
topframe.style.height=Math.max(ifrDoc.documentElement.scrollHeight,ifrDoc.documentElement.clientHeight)+”px”;
}
jq:
$(window).load(function(){
var topframe=$(“#ifr”);
var ifrDoc=$(“#ifr”).contents();
topframe.height(ifrDoc.height());
})
跨域:(参考文章)
location.hash 实现跨域 iframe 自适应
https://www.oschina.net/code/snippet_54100_592
非跨域:
<iframe src=”https://www.test.org/myiframe.html” frameborder=”0″ width=”100%” id=”ifr” height=”100%” marginwidth=”0″ marginheight=”0″></iframe>
原生js:
window.onload=function(){
var topframe=document.getElementById(“ifr”);
var ifrDoc=topframe.contentDocument|| topframe.contentWindow.document;
topframe.style.height=Math.max(ifrDoc.documentElement.scrollHeight,ifrDoc.documentElement.clientHeight)+”px”;
}
jq:
$(window).load(function(){
var topframe=$(“#ifr”);
var ifrDoc=$(“#ifr”).contents();
topframe.height(ifrDoc.height());
})
跨域:(参考文章)
location.hash 实现跨域 iframe 自适应
https://www.oschina.net/code/snippet_54100_592
在不声明Doctype文档申明的情况下,IE默认就是Quirks Mode即怪异模式(ie调试工具文档模式中有标识)。其实不止ie,要文档没申明Doctype其它浏览器也会识别成怪异模式即BackCompat模式,此时document.compatMode==”BackCompat”
另外,当文档有了标准声明即Standards Mode下, document.compatMode 的值等于 “CSS1compat”
另外需要注意的是:
对于margin和padding,其任意方向的百分比值,参照都是包含块的宽度。
详细解说,站外文章:
https://acgtofe.com/posts/2014/06/percentage-in-css/
::selection {
background: rgba(231,105,105,0.7);
}
手机上的浏览器如果点击或长按文字,图片,链接,或其它页面元素也会出现选中高亮的颜色,自定义方法:
-webkit-tap-highlight-color: rgba(0,0,0,1);
-moz-tap-highlight-color: rgba(0,0,0,1);
-o-tap-highlight-color: rgba(0,0,0,1);
-ms-tap-highlight-color: rgba(0,0,0,1);
tap-highlight-color: rgba(0,0,0,1);
将rgba第4个参数属性写成0,即透明不可见,即:tap-highlight-color: rgba(0,0,0,0);
或
tap-highlight-color: transparent;
qq手机浏览器直接不支持选中高亮色的自主义,无语…
固用css3做单行的自适应布局,结合使用display: -webkit-box; + -webkit-box-flex 还行,其它布局属性,考虑到手机浏览器普遍不支持,不建议使用!
其实是弹出层的z-index值比ZeroClipboard.js设置的复制层z-inex:99 大,flash所在的复制层被弹出层遮盖住了而已,而不是在弹出层中调用ZeroClipboard复制插件会失效!
弹出层显示时,可用调试器查看ZeroClipboard的复制层其实是有正常加载的,调下z-index值就能看到了!!
即是说:
<script>
window.onload=function(){
document.write(“ttttt!!”);
}
</script>
会重写整个页面
即是说:
<script>
window.onload=function(){
document.write(“ttttt!!”);
}
</script>
会重写整个页面
IE6下为行内块元素单独设置
margin:/* (父级所属line-height – 自身高度)/2px 0 */;
(function(){})();
!function(){}();
~function(){}();
后2种,使用用void操作符: ~操作符,!操作符,别说你知道….
break是直接退出switch语句
return是退出该函数 也就是switch语句块后面的语句也不执行了,这里break;就可忽略不写了。
当然switch case 带return,前提是switch 在函数里面,函数才能使用return!
https://api.map.baidu.com/lbsapi/getpoint/index.html
或
https://developer.baidu.com/map/jshome.htm 页面的“逆/地理编码” api 接口