close

處理網頁常用到的限制如 鎖定右鍵與防止列印, 以下是相關的解決方式

1. Disable right click menu (鎖定右鍵):

方法: 透過於body tag 中, 加上 oncontextmenu="javascript:return false;"

註: 此方法不適用FireFox

2. Disable print page (防止列印)

方法:
Step1. 新建一 css file, 內容為 body { display: none; }
Step2. 於html head tag 中, 加上該 css , 並加上 media = "print" 的屬性(attribute)

結果: 當使用者使用網頁列印功能時, 不論印出或預覽頁面, 顯示的內容皆為空白, 這樣就可以達到不允許列印功能的需求了

註: 此方法無法防止 print screen 或 chrome的save as 功能

3. Disable drag & select (防止選取複製)

方法: 透過於body tag 中, 加上 ondragstart="javascript:return false;" 與 onselectstart="javascript:return false;"


以上, 已在 ie6/ie7/ie8/chrome/firefox 測試過, 應可滿足大部分需求.

arrow
arrow
    全站熱搜

    nengchung 發表在 痞客邦 留言(0) 人氣()