用到的属性
但是通常我们还会添加 pointer-events: none 来禁用掉对应div
但是这样,问题就出来了---------- cursor: not-allowed 这个属性失效了。
在目标div上再套一层div,将 cursor: not-allowed 加到父盒子上,目标div保留 pointer-events: none
<style type="text/css">div{width:300pxborder:1px solid redmargin:10pxoverflow:hidden}
.nowrap{white-space:nowrap}
</style>
<div class="nowrap">这是一段很长的文字,中间没有空格,也没有换行,它不会自动换行直到被截取掉</div>
<div>这是一段很长的文字,中间没有空格,也没有换行,但它会自动换行</div>
上面两个div里超宽的文字,第一个里面的被禁止换行,然后超宽的被截取了;第二个不做设置,于是自动换行了。
网页上禁止复制主要靠JavaScript来实现。<BODY oncontextmenu="return false" onselectstart="return false"
ondragstart="return false" onbeforecopy="return false" oncopy=document.selection.empty() onselect=document.selection.empty()>
-----------------------------------------------
防止复制的js
-----------------------------------------------
<SCRIPT language=JavaScript1.2>
function disableselect(e){
return false}
function reEnable(){return true
}
file://if IE4+
document.onselectstart=new Function ("return false")
file://if NS6
if (window.sidebar){
document.onmousedown=disableselect
document.onclick=reEnable
}
</SCRIPT>
<SCRIPT language=JavaScript type=text/JavaScript>
<!--
function MM_reloadPage(init) {//reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidthdocument.MM_pgH=innerHeightonresize=MM_reloadPage}}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload()
}
MM_reloadPage(true)
//-->
</SCRIPT>
-------------------------------------------------------
防止下载的js
-------------------------------------------------------
<noscript><iframe src=""></iframe></noscript>
--------------------------------------------------------
下面是防止右键的js:
--------------------------------------------------------
<script language="JavaScript">
<!--
if (window.Event)
document.captureEvents(Event.MOUSEUP)
function nocontextmenu() {
event.cancelBubble = true
event.returnValue = false
return false
}
function norightclick(e) {
if (window.Event){
if (e.which == 2 || e.which == 3)
return false
}else{
if (event.button == 2 || event.button == 3){
event.cancelBubble = true
event.returnValue = false
return false
}
}
}
document.oncontextmenu = nocontextmenu// for IE5+
document.onmousedown = norightclick// for all others
//-->
</script>