2010-06-02 56 views
2

對於IE6,是否有與-moz-user-select/-webkit-user-select等效的內容?無法選擇的文本 - 跨瀏覽器解決方案

我希望我的網頁上的文字不能在所有主流瀏覽器中選擇。

什麼是最好的解決方案呢?

+4

爲什麼你會想要這樣做?!?這是否爲你的內容提供了某種保護(比如臭名昭着的'禁用右鍵點擊'腳本)?我認爲這隻會讓用戶感到惱火......(尤其是那些有着奇怪習慣的人,比如選擇他們正在閱讀的文本) – Marc 2010-06-02 06:28:46

+1

首先會讓用戶惱火,如果你想保護內容,那麼不要把它放在互聯網上,因爲如果它真的很重要,人們需要它,我會有很多方法來擺脫任何保護,只是一個簡單的谷歌搜索將爲他們提供許多方法。 – 2010-06-02 06:36:32

+14

停止支持IE6 – Jason 2010-06-02 06:37:36

回答

1

這裏的例子

<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Unselectable text</title> 
</head> 

<body style="height: 100%; padding: 0; margin: 0;"> 

<style> 
    .column {width: 30em; margin: 1em;} 
    p {position: relative; z-index: 1; //height: 100%;} /* you can remove //height if declare doctype */ 
    .unselector {display: block; position: absolute; z-index: 2; width: 100%; height: 100%; top: 0; left: 0;} 
    .unselector img {display: block; position: absolute; z-index: 3; width: 100%; height: 100%;} 
</style> 

    <div class="column"> 
    <p> 
    <span class="unselector"><img src="1.gif" alt="" border="0" /></span> 
    Activists on&nbsp;ships raided by&nbsp;Israeli commandos cast doubt on&nbsp;Israel's version of&nbsp;events that led&nbsp;to at&nbsp;least nine deaths. Yes, the webpage is currently not available. 
    </p> 
    </div> 

</body> 
</html> 

附: 1.gif是透明的1px * 1px圖像

+0

爲什麼使用img如果你可以「不使用」img? – vsync 2011-05-23 21:01:19

1

如果這是一個小的元素遮罩,我會去在文本上有一個空的DIV,並給予DIV絕對位置,Z-index高於文本的位置。確保DIV正在迎頭趕上。

相關問題