closeWindow

function closeWindow(){
if(navigator.appName==”Microsoft Internet Explorer” || isIE11()) {
if (parent.window.external.Document==null) {
// IE with no wrapper application
// VBBrowse looks for the status ExitProgram to execute
// Timeout is presented to give vbbrowse time to close
parent.window.status = “ExitProgram”;
parent.window.status = “”;
setTimeout(‘parent.window.close()’, 2000);
} else {
// IE with Netkey wrapper
parent.window.external.Document.CurrentScreen = parent.window.external.Document.Screens(‘Attract Loop Start Screen’);
}
} else {
var win=window.open(“,’_self’,”);
win.close();
}
}

function isIE11(){
return /trident/7/.test(navigator.appVersion.toLowerCase());
}

html base64 img 图片显示

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAkCAYAAABIdFAMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAHhJREFUeNo8zjsOxCAMBFB/KEAUFFR0Cbng3nQPw68ArZdAlOZppPFIBhH5EAB8b+Tlt9MYQ6i1BuqFaq1CKSVcxZ2Acs6406KUgpt5/LCKuVgz5BDCSb13ZO99ZOdcZGvt4mJjzMVKqcha68iIePB86GAiOv8CDADlIUQBs7MD3wAAAABJRU5ErkJggg%3D%3D"/>

js禁用esc, backspace

<script >
function keydown(e){
    if(e==null)e = window.event;
    if(e.keyCode==27|| e.keyCode==8){
        e.keyCode=0;
        e.cancelBubble=true;
        e.returnValue=false;  
        return false;      
    }
}
document.onkeypress = keydown;
document.onkeydown = keydown;
</script>

js遮罩

$j("body").append('<div id="popupLoading"></div><div id="popupLoadingBg"></div>');   

$j("#popupLoading").css({
        width:"60px",height:"60px",
        position:"fixed",top:"50%",left:"50%",zIndex:100001,
        marginLeft:"-30px",marginTop:"-30px",
        background:"url(../images/loading.gif) no-repeat"
});
    
$j("#popupLoadingBg").css({
        width:"100%",height:"100%",
        position:"fixed",top:0,left:0,zIndex:100000,
        backgroundColor:"#000",opacity:'0.3'
});

阻止网页内部滚动条mousewheel事件冒泡

利用鼠标滚轮对网页内部无素滚动条触发滚动事件,当滚动条到达元素顶部或底部时不触发浏览器窗口的滚动事件。

通过调用以下函数实现:

  1. function preventScroll(id){  
  2.     var _this = document.getElementById(id);  
  3.     if(navigator.userAgent.indexOf("Firefox")>0){  
  4.         _this.addEventListener('DOMMouseScroll',function(e){  
  5.             _this.scrollTop += e.detail > 0 ? 60 : -60;     
  6.             e.preventDefault();  
  7.         },false);   
  8.     }else{  
  9.         _this.onmousewheel = function(e){     
  10.             e = e || window.event;     
  11.             _this.scrollTop += e.wheelDelta > 0 ? -60 : 60;     
  12.             return false;  
  13.         };  
  14.     }  
  15.     return this;  

 IE9不支持类似 e.returnValue = false  这种写法,相应的地方改成return false即可。