• 19/08/2013 • 4 phút đọc • 13 lượt xem

Cách chống View Source

Việt Lâm Coder
Việt Lâm Coder
Senior Fullstack & System Architect • Hotline: 0944.71.4545

Các cách chống viewsource

1. Dùng Java Script để tạo alert khi người ta click chuột phải để xem Source, ngăn không cho họ làm điều đó
Cách này vẫn có thể View Source khi chọn ở menu View của browser
2. Dùng 1 đoạn code như thế này :

Các cách chống viewsource

1. Dùng Java Script để tạo alert khi người ta click chuột phải để xem Source, ngăn không cho họ làm điều đó
Cách này vẫn có thể View Source khi chọn ở menu View của browser
2. Dùng 1 đoạn code như thế này :

<BODY oncontextmenu="return false" ondragstart="return false" onselectstart="return false">


cho tag <  body > của bạn
Có thể View Source khi chọn ở menu View của browser
3. Dùng flash, hèm, thế thì phải thực sự kha khá về flash 1 tẹo, không thì chán lắm vả lại làm toàn bộ = flash thì fải tính đến khá nhiều công đoạn như tính sao cho visitor không phải chờ lâu để load, làm thế nào cho ấn tượng ..v...v...
4. Dùng một ít HTML code, để mở ra 1 trang mới , không có menu gì gì hết
ví dụ như thế này

<a href="javascript:PopUp('http://veoclub.net/irc/','Pager','700','500','1','1','1','1')"><font color="red"><b>VeoChat</b></font></a>


Cách này chống View Source cũng khá hiệu quả
5. Cách này khá hay, có vẻ khá hữu hiệu, mọi người thử xem sao
Đầu tiên copy toàn bộ code này đã, rồi save thành 1 file html, sau đó mở ra, tống toàn bộ HTML code mà bạn muốn che giấu vào đó, và click nút "Encrypt" , và copy đoạn mã HTML đã được encrypt (mã hoá) đó, paste lại vào file mà bạn cần hide source code, Alt + F +S ==> xong

<html>

<head>

<title>Source Code Encrypter</title>

</head>

<script language=JavaScript>

<!--

//////////////////////////////////////////////////////////////////

// Source Code Encrypter v1.0 //

//////////////////////////////////////////////////////////////////

// //

// This JavaScript can be freely used as long as this message //

// stays here in the header of the script. Any modifications //

// and bugs found (and fixed) are appreciated. //

// Script submitted/featured on Dynamicdrive.com //

// Visit http://www.dynamicdrive.com for source code //

// Svetlin Staev, thewebmonster@altavista.com //

////////////////////////////////////////////////////////////////// var i=0; var ie=(document.all)?1:0; var ns=(document.layers)?1:0; function initStyleElements() /* Styles for Buttons Init */

{ var c = document.pad; if (ie)

{

//c.text.style.backgroundColor="#DDDDDD"; c.compileIt.style.backgroundColor="#C0C0A8"; c.compileIt.style.cursor="hand"; c.select.style.backgroundColor="#C0C0A8"; c.select.style.cursor="hand"; c.view.style.backgroundColor="#C0C0A8"; c.view.style.cursor="hand"; c.retur.style.backgroundColor="#C0C0A8"; c.retur.style.cursor="hand"; c.clear.style.backgroundColor="#C0C0A8"; c.clear.style.cursor="hand";

} else return;

}



/* Buttons Enlightment of "Compilation" panel */ function LightOn(what)

{ if (ie) what.style.backgroundColor = '#E0E0D0'; else return;

} function FocusOn(what)

{ if (ie) what.style.backgroundColor = '#EBEBEB'; else return;

} function LightOut(what)

{ if (ie) what.style.backgroundColor = '#C0C0A8'; else return;

} function FocusOff(what)

{ if (ie) what.style.backgroundColor = '#DDDDDD'; else return;

}

/* Buttons Enlightment of "Compilation" panel */ function generate() /* Generation of "Compilation" */

{ code = document.pad.text.value; if (code)

{ document.pad.text.value='Compiling...Please wait!'; setTimeout("compile()",1000);

} else alert('First enter something to compile and then press CompileIt')

} function compile() /* The "Compilation" */

{ document.pad.text.value=''; compilation=escape(code); document.pad.text.value="<script> <!-- document.write(unescape(""+compilation+"")); //--> </script>"; i++; if (i=1) alert("Page compiled 1 time!"); else alert("Page compiled "+i+" times!");

} function selectCode() /* Selecting "Compilation" for Copying */

{ if(document.pad.text.value.length>0)

{ document.pad.text.focus(); document.pad.text.select();

} else alert('Nothing for be selected!')

} function preview() /* Preview for the "Compilation" */

{ if(document.pad.text.value.length>0)

{ pr=window.open("","Preview","scrollbars=1,menubar=1,status=1,width=700,height=3 20,left=50,top=110"); pr.document.write(document.pad.text.value);

} else alert('Nothing for be previewed!')

} function uncompile() /* Decompiling a "Compilation" */

{ if (document.pad.text.value.length>0)

{ source=unescape(document.pad.text.value); document.pad.text.value=""+source+"";

} else alert('You need compiled code to uncompile it!')

}

// -->

</script>

<body bgcolor=white topmargin=0 leftmargin=0 marginheight=0 marginwidth=0 initStyleElements()>

<table border=0 width=100% cellspacing=0 cellpadding=0>

<tr>

<td width=100% height="23"></td>

</tr>

<tr>

<td width=100% height=23></td>

</tr>

<tr>

<td width=100%>



<!-- Compilation Panel -->

<form method=post name=pad align=center>

<textarea rows=11 name=text cols=58 style="background-color:#EBEBEB;width:95%"></textarea><br>

<input type=button value=Encrypt name=compileIt onClick=generate() LightOn(this) LightOut(this)>

<input type=button value=Select name=select onClick=selectCode() LightOn(this) LightOut(this)>

<input type=button value=Preview name=view onClick=preview() LightOn(this) LightOut(this)>

<input type=button value=Source name=retur onClick=uncompile() LightOn(this) LightOut(this)>

<input type=reset value=Clear name=clear LightOn(this) LightOut(this)>

</form>

<!-- Compilation Panel -->



</td>

</tr>

</table>

</body>

</html>
Việt Lâm Coder

Việt Lâm Coder

Tác giả bài viết và chuyên gia quản trị website. Nếu bạn gặp khó khăn trong quá trình thực hiện hoặc có nhu cầu thiết kế website, lập trình web app Laravel, hãy liên hệ ngay với tôi qua Hotline / Zalo: 0944.71.4545.

☕ Mời Tác Giả Ly Cà Phê Ấm Lòng

Nếu bài viết này giúp ích cho công việc của bạn, hãy tiếp thêm động lực cho tác giả duy trì kho tri thức bằng một ly cà phê ấm lòng nhé!

Mã QR ủng hộ tác giả
Ngân hàng TMCP Quân Đội (MB Bank)TONG VIET LAM

Có Thể Bạn Quan Tâm

Cách Mở Tab Ẩn Danh Trên Safari MacBook Đơn Giản

Cách mở tab ẩn danh trên Safari MacBook sẽ giúp cho người dùng có thể bảo vệ quyền riêng tư và duyệt web một cách an toà...

Hướng dẫn 5 cách tắt update Windows 11 vĩnh viễn chi tiết nhất

Mặc định Windows 11 sẽ được tự động cập nhật trong nền. Tuy nhiên nếu vì lý do nào đó mà bạn không muốn nhận các bản...

Hướng dẫn trỏ file hosts cho domain trên hệ điều hành Windows

– Làm cách nào để 1 website có thể hoạt động trên Share hosting, VPS, Server mà không cần cấu hình các record DNS cho do...

Kích hoạt Cloudflare Turnstile trong Contact Form 7 chống spam

Cloudflare Turnstile là giải pháp xác thực không dùng CAPTCHA giúp bảo vệ website WordPress khỏi spam một cách nhẹ nhàng...

Cách Sử Dụng DeepSeek R1 Miễn Phí Trong Visual Studio Code Với Cline?

Hãy đối mặt với thực tế: Các trợ lý lập trình AI như GitHub Copilot thì tuyệt vời, nhưng chi phí đăng ký của chúng có th...

Gmail API – Tất cả những gì bạn cần biết - 2025

Nếu bạn đang tìm cách tích hợp Gmail vào các ứng dụng của riêng mình thì Gmail API chính là thứ bạn cần! Gmail là một lự...

Hướng dẫn tạo màn hình desktop ảo bằng Task View trên Surface Windows 11

Việt Lâm Coder sẽ hướng dẫn tạo lập nhiều màn hình desktop ảo bằng Task View trên Surface Windows 11 để sắp xếp các tác...

How to Transfer PuTTY Sessions To Another Windows Machine

his is an user contributed article. PuTTY is a terminal emulator application which can act as a client for the SSH, T...

Hướng dẫn cách kiểm tra cổng đang mở (Check open port) trên linux

Với nhiều năm kinh nghiệm hỗ trợ Khách hàng của Tenten, chúng tôi nhận thấy việc thường xuyên theo dõi kiểm tra hoạt độn...

Kiểm tra tất cả các port mà Cyber Panel đang cần có được mở hay không ?

Để kiểm tra tất cả các port cùng một lúc, bạn có thể sử dụng lệnh: netstat -tulpn | grep -E ':(8090|80|443|21|40110|401...

Hướng dẫn cài đặt KeyHelp Panel

Tóm tắt về KeyHelp Bạn đã có phần cứng tốt nhất cho các dự án Internet của mình nhưng việc quản lý phức tạp, hiệu suất...

Tổng hợp danh sách Control Panel VPS free tốt nhất hiện nay

Control Panel VPS free cung cấp một lựa chọn tuyệt vời cho những người dùng muốn quản lý VPS một cách dễ dàng và hiệ...