為保護原創內容防止被直接複製,可通過 JavaScript 和 CSS 禁用選中與複製操作。本文提供兼容 IE 和 Firefox 的完整方案。
<script language="javascript">
document.onselectstart = new Function('event.returnValue=false;'); // 禁止選中,從而禁止複製
</script>
<style type="text/css">
body { -moz-user-select: none; }
</style>
<style>
/* 現代瀏覽器統一禁用選中 */
body {
-webkit-user-select: none; /* Chrome/Safari */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* IE10+/Edge */
user-select: none; /* 標準語法 */
}
</style>
<script>
// 針對舊版 IE 額外處理
document.onselectstart = function() { return false; };
</script>
建議: 版權保護更有效的手段是:添加水印、數字指紋、法律聲明、監控監測盜版,而非單純依賴前端限制。