οncοntextmenu='return false' //禁止右键
οndragstart='return false' //禁止拖动
onselectstart ='return false' //禁止选中
οnselect='document.selection.empty()' //禁止选中
οncοpy='document.selection.empty()' //禁止复制
onbeforecopy='return false' // 禁止复制
οnmοuseup='document.selection.empty()'
*{
moz-user-select: -moz-none
-moz-user-select: none
-o-user-select:none
-khtml-user-select:none
-webkit-user-select:none
-ms-user-select:none
user-select:none
}
长按事件document.addEventListener("touchstart", function (e) { console.log('touchstart') timer = setTimeout(function () { console.log('LongPress') e.preventDefault() LongPress(parentObj) }, 800) }) document.addEventListener("touchmove", function (e) { console.log('touchmove') clearTimeout(timer) timer = 0 }) document.addEventListener("touchend", function (e) { console.log('touchend') clearTimeout(timer) if (timer != 0) { alert('这是点击,不是长按') } return false })这个可以通过绝对定位,配合left设置 或者translate去实现left的方法:
比如让class为menu的元素宽为300px,高100%的,设置left为-300px;在这期间可以加一个过渡transition:left 0.3s ...;
然后让class为menu active的元素设置 left设置为0就可以了 ,在这期间可以加一个过渡transition:left 0.3s ...;
然后可以通过Jquery的toggleClass('active')来实现切换
translate
比如让class为menu的元素宽为300px,高100%的,设置left为-300px;在这期间可以加一个过渡transition:left 0.3s ...;
然后让class为menu active的元素设置 transform:translate3d(-300px,0,0) ,在这期间可以加一个过渡transition:left 0.3s ...;
然后可以通过Jquery的toggleClass('active')来实现切换
这个过程中 需要注意 body需要overflow:hidden(不然会有滚动条,可设置overflow-x即可)
left 和 translate 最好用translate ,translate3d可以开启GPU硬件加速,性能会更好,体验会更流畅
我github有类似小组件样式
github: IFmiss
希望能解决你的问题
<!doctype html>
<html>
<head><title>无标题文档</title></head>
<body>
<!--插入按钮 开始-->
<input type="button" value="弹出对话框" onclick="MsgBox()" />
<!--插入按钮 结束-->
<!--引用JS代码以达到弹出对话框目的 开始-->
<script language="javascript">
function MsgBox() //声明标识符
{
alert("我是对话框的内容")//弹出对话框
}
</script>
<!--引用JS代码以达到弹出对话框目的 结束-->
</body>
</html>
扩展资料:方法参数详解
参数解释:
window.open 弹出新窗口的命令;
'page.html' 弹出窗口的文件名;
'newwindow' 弹出窗口的名字(不是文件名),非必须,可用空''代替;
height=100 窗口高度;
width=400 窗口宽度;
top=0 窗口距离屏幕上方的象素值;
left=0 窗口距离屏幕左侧的象素值;
toolbar=no 是否显示工具栏,yes为显示;
menubar,scrollbars 表示菜单栏和滚动栏。
resizable=no 是否允许改变窗口大小,yes为允许;
location=no 是否显示地址栏,yes为允许;
status=no 是否显示状态栏内的信息(通常是文件已经打开),yes为允许;