網頁無法查看源代碼,網站右鍵點擊不能查看源代碼,頁面添加了禁止右鍵,如何查看源代碼呢?這篇文章主要介紹了javascript實現禁止右鍵和F12查看源代碼的代碼,需要的朋友可以參考下,這是為了別人不看你的代碼,
沈陽網站建設公司建議對于不懂得人哦,如果老手是防不住的!
在你想要查看的網頁前面添加:
view-source: 即可
舉例,查看百度的源代碼 view-source:https://www.baidu.com/
網站右鍵無法查看源代碼解決方法有哪些?
javascript實現禁止右鍵和F12查看源代碼如下:
function click(e) {
if (document.all) {
if (event.button==2||event.button==3) { alert("歡迎光臨寒舍,有什么需要幫忙的話,請與站長聯系!謝謝您的合作?。?!");
oncontextmenu='return false';
}
}
if (document.layers) {
if (e.which == 3) {
oncontextmenu='return false';
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
document.oncontextmenu = new Function("return false;")
document.onkeydown =document.onkeyup = document.onkeypress=function(){
if(window.event.keyCode == 123) {
window.event.returnValue=false;
return(false);
}
}
<--123——112是F1-F12的代碼數-->
猜您關注:網站制作,沈陽萬詞霸屏,網站制作教程,萬詞霸屏,大連網站推廣