2010-06-02 47 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正在迎头赶上。

相关问题