2014年4月20日 星期日

javascript - 解除封鎖右鍵

(function() {
var doc = document;
var body = doc.body;
var html = doc.documentElement;
html.onselectstart = html.oncopy = html.oncut = html.onpaste = html.onkeydown = html.oncontextmenu = html.onmousemove = body.oncopy = body.oncut = body.onpaste = body.onkeydown = body.oncontextmenu = body.onmousemove = body.onselectstart = body.ondragstart = doc.onselectstart = doc.oncopy = doc.oncut = doc.onpaste = doc.onkeydown = doc.oncontextmenu = doc.onmousedown = doc.onmouseup = null;
body.style.webkitUserSelect = 'auto';

function defaultHandler(event) {
event.returnValue = true;
}
for (event_type in ['selectstart', 'copy', 'cut', 'paste', 'keydown', 'contextmenu', 'dragstart']) {
html.addEventListener(event_type, defaultHandler);
body.addEventListener(event_type, defaultHandler);
doc.addEventListener(event_type, defaultHandler);
}

var jQuery = window.jQuery;
if (jQuery) {
jQuery(doc).unbind();
jQuery(body).unbind();
}

var $Fn = window.$Fn;
if ($Fn) {
try {
$Fn.freeElement(doc);
$Fn.freeElement(body);
} catch (e) {}
}

var jindo = window.jindo;
if (jindo) {
jindo.$A = null;
}

})();


---------------------------------------------------------

減肥版

(function() {var doc = document;var body = doc.body;var html = doc.documentElement;html.onselectstart = html.oncopy = html.oncut = html.onpaste = html.onkeydown = html.oncontextmenu = html.onmousemove = body.oncopy = body.oncut = body.onpaste = body.onkeydown = body.oncontextmenu = body.onmousemove = body.onselectstart = body.ondragstart = doc.onselectstart = doc.oncopy = doc.oncut = doc.onpaste = doc.onkeydown = doc.oncontextmenu = doc.onmousedown = doc.onmouseup = null;body.style.webkitUserSelect = 'auto';function defaultHandler(event) { event.returnValue = true;}for (event_type in ['selectstart', 'copy', 'cut', 'paste', 'keydown', 'contextmenu', 'dragstart']) { html.addEventListener(event_type, defaultHandler); body.addEventListener(event_type, defaultHandler); doc.addEventListener(event_type, defaultHandler);}var jQuery = window.jQuery;if (jQuery) { jQuery(doc).unbind(); jQuery(body).unbind();}var $Fn = window.$Fn;if ($Fn) { try { $Fn.freeElement(doc); $Fn.freeElement(body); } catch (e) {}}var jindo = window.jindo;if (jindo) {jindo.$A = null;}})();

0 意見:

張貼留言

 

MangoHost Copyright © 2009 Cookiez is Designed by Ipietoon for Free Blogger Template