猿问

JS的闭包封装,如何完成调用?

varprotection=(function(){
vardata={
suffix:"com",
main:"www.",
red:"bai",
beauty:"du",
dot:"."
}
vard=(data.main+data.red+data.beauty).toString()+data.dot+data.suffix;
varurl=function(){
if(document.location.host!="www.baidu.com"){
location.href=location.href.replace(document.location.host,'www.baidu.com');
}
returnlocation.href;
}
varauthentication=function(){
if(window.location.host.indexOf(d)<0){
//$("body").remove();
document.querySelector('html').removeChild('body');
returnfalse
}
returntrue
}
varshield=function(){
document.addEventListener('keydown',function(e){
e=window.event||e;
varkeycode=e.keyCode||e.which;
//屏蔽Ctrl+s保存页面
//
//
vardisableCopy=function(){
if(e.ctrlKey&&keycode==83){
e.preventDefault();
window.event.returnValue=false;
}
}
vardisableSource=function(){
//屏蔽Ctrl+u查看页面的源代码
if(e.ctrlKey&&keycode==85){
e.preventDefault();
window.event.returnValue=false;
}
}
vardisableF12=function(){
//屏蔽F12
if(keycode==123){
e.preventDefault();
window.event.returnValue=false;
}
}
vardisbaleConsole=function(){
//屏蔽Ctrl+shift+i屏蔽调出控制台和F12一样
if(e.ctrlKey&&e.shiftKey&&keycode==73){
e.preventDefault();
window.event.returnValue=false;
}
}
});
}
varfacility={
geturl:url,
checkurl:authentication,
shield:shield
}
returnfacility;
})();
这段代码应该怎么修改才可以分别调用内部的方法?
一只甜甜圈
浏览 846回答 2
2回答
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答