`
redleaf
  • 浏览: 127450 次
  • 性别: Icon_minigender_1
社区版块
存档分类
最新评论

document.onselectstart=function(){return false;} 引起的拖动问题

阅读更多
在网页中拖动时,会引起某些文字或一些内容被选中,导致网页中蓝蓝的一片,视觉效果很差,所以我加了个
document.onselectstart=function(){return false;}这样子,拖动时网页中的内容是不会被选中了,但也随之带来了另一个问题:
在拖动时,如果遇到滚动条的话,那我就拖不下去了,因为滚动条不会自动的向下滚或是向上滚了,我只能在当前视线范围内拖动,这个问题在没加document.onselectstart=function(){return false;}之前是没有的,大家有没有办法解决此滚动条滚动问题,万分感谢!!!

分享到:
评论
3 楼 Mr_yuhualing 2014-09-04  
obj.onmousedown = function(ev) {
    return false;
};
2 楼 skyman531 2013-03-28  
我也遇到了同样的问题哦,请问LZ解决了没有?是怎样解决的?
1 楼 redleaf 2007-06-27  
就是我的滚动条要随着我的拖动自动的滚动,这个怎么做?

相关推荐

    js禁止页面复制功能禁用页面右键菜单示例代码.docx

    document.body.onselectstart = function(){ return false; } ``` 这将禁用页面的选中功能,从而禁用复制功能。 禁用剪切功能 禁用剪切功能可以使用 `oncut` 事件,例如: ``` <script type="text/javascript"> ...

    网页禁止下载、复制代码和使用右键

    document.onselectstart = new Function("return false"); } ``` 2. **Firefox等非IE浏览器的处理** - 判断`window.sidebar`的存在与否(Firefox的一个特性)。 ```javascript if (window.sidebar) { // for ...

    将不可复制的网页内容转换为可复制粘贴的工具

    - **禁用鼠标选择**:通过JavaScript设置`document.body.onselectstart = function() { return false; }`,这样当用户尝试用鼠标拖动选中文本时,系统会阻止这一行为。 - **禁用右键菜单**:通过设置`document.body....

    利用WebBrowser控件只读访问文档

    document.onselectstart = function() { return false; } document.oncopy = function() { return false; } <iframe id="mhtFrame" src="path\to\yourfile.mht"> ``` 将这段HTML设置为WebBrowser控件的...

    div拖动基础div拖动基础

    document.onselectstart = function () { return false; }; } this.drag = function (e) { e = e || event; me.foo.style.top = e.clientY - me.foo.oOffset.y + "px"; me.foo.style.left = e.clientX - me....

    禁止鼠标右击 网站定制自己的右键菜单

    <body ondragstart="window.event.returnValue=false" oncontextmenu="window.event.returnValue=false" onselectstart="event.returnValue=false"> ``` 这段代码不仅可以阻止右键菜单的出现,还可以防止文本的选择...

    网页使用JS禁用鼠标的几种方法

    <body ondragstart="window.event.returnValue=false" oncontextmenu="window.event.returnValue=false" onselectstart="event.returnValue=false"> ``` 上述代码中,`ondragstart`用于阻止拖拽,`onselectstart`...

    出现问题a is defined高手帮忙

    G.mapCover.onselectstart = function() {return false}; return buttonContainerDiv; }; DragZoomControl.prototype.getDefaultPosition = function() { return new GControlPosition(G_ANCHOR_TOP_LEFT, ...

    javascript禁用键盘功能键让右击及其他键无效.docx

    <body onselectstart="return false"> <!-- 页面内容 --> ``` #### 3. 禁止拖拽 对于网页中的元素,如果不想让用户进行拖拽,可以使用`ondragstart`事件: ```html <body ondragstart="return false"> <!-- ...

    如何保护自己的网页代码不被人窥视.pdf

    <body oncontextmenu='return false' ondragstart='return false' onselectstart='return false'> ``` 2. **禁止网页另存为**:在`<noscript>`标签内添加`<iframe>`,当用户尝试另存网页时,会加载一个无效的URL...

    网页禁用右键菜单和鼠标拖动选择方法小结

    <body onContextMenu="return false" onSelectStart="return false"> ``` 2. 或者,将两个事件处理函数绑定到同一个JavaScript函数: ```javascript document.onselectstart = mylock1; document.oncontextmenu = ...

    网页防复制代码

    document.body.onselectstart = function() { return false; } document.body.onmousedown = function(e) { if (e.button == 0) { e.preventDefault(); } } ``` 3. CSS样式控制:通过CSS样式可以设置`user-...

    JavaScript禁止页面操作的示例代码

    document.onselectstart = function() { return false; }; } // For NS6 else if (window.sidebar) { document.onmousedown = function() { return false; }; document.onclick = function() { return true; }; }...

    完美实现js拖拽效果 return false用法详解

    在拖拽功能中,`return false`被用于阻止`onmousedown`事件的默认行为,即防止在拖动元素时选中文本。不过,需要注意的是,`return false`并不总是阻止所有默认行为,例如在IE浏览器中,它不能阻止`onselectstart`...

    解除CHROME网页复制限制的两个方法(代码和插件)

    document.body.onselectstart = function() { return false; } document.body.onmousedown = function(e) { e.preventDefault(); } ``` 要解除这种限制,你可以使用浏览器的开发者工具(F12键打开)。在Elements...

    js使用小技巧

    禁止选取<body oncontextmenu="return false" ondragstart="return false" onselectstart ="return false" onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return ...

    【JavaScript源代码】JavaScript实现简单拖拽效果.docx

    JavaScript 实现简单的拖拽效果是网页交互中常见的一种功能,主要通过监听鼠标事件来实现。在本实例中,我们将分析如何使用 JavaScript 和 CSS 创建一个可拖动的蓝色盒子。 首先,我们需要创建 HTML 结构,这里包含...

    一些常用的JavaScript

    <body oncontextmenu="return false" ondragstart="return false" onselectstart="return false" onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return false" ...

    网页保护方法大全.pdf

    使用`document.ondragstart=new Function("return false")`,可以防止用户将页面中的内容拖拽到其他地方,这对于防止页面布局和元素被随意更改是有帮助的。 5. 防止拖拽图片到浏览器 通过`document.onmousedown=...

    常用代码大全

    <body oncontextmenu="return false" ondragstart="return false" onselectstart="return false" onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return false" ...

Global site tag (gtag.js) - Google Analytics