首先你要确定你是要禁用全局的还是指定控件 ,如我只要禁用一个文本框的上下键 代码如下: NoExec = function(event) { var k = event.which || event.keyCode; if (k == 13 || k == 38 || k == 40) { if ($("#atWinByArea").attr("id")) { if (event.which) {//火狐 event.preventDefault(); } else {//IE、Chrome event.returnValue = false; } } } downAt(event); } var target = document.getElementById("saytext"); //指定的...
之前一直没测试chrome ,今天事情不太多,就测试了一下,发现给div加的 onmouseleave事件在chrome 中不起效果; 后来发现解决办法用jquery的方式实现 例如 代码如下: <div id=‘aaa class=divfloat " onmouseleave=$(this).slideUp(); style=background-color: White; width:553px; position: absolute;left:" + (event.offset().left - 420) + "px;top:" + (event.offset().top + 25) + "px;>aaaaaa");
实例代码一见: 代码如下: #main div{position:absolute;width:220px;height:150px;border:1px solid #999;} var a; document.onmouseup = function() { if (!a) return; a = ""; }; document.onmousemove = function(d) { if (!a) return; d=d||event; a.style.left = (d.clientX - b) + "px"; a.style.top = (d.clientY - c) + "px"; }; function $(o, e) { a = o; b = e.clientX - parseInt(a.style.left); c = e.client...
一直以来,Chrome控制台都缺少象IE调试台那样的多行执行模式。 今天意外发现Chrome其实也支持多行模式。默认在Chrome控制台上输入回车后会执行该命令,只需要通过输入Shift+Enter来新建行即可。
网上有很多说在里加一句:或者就可以解决,实际测试根本没有效果,原来是在ScrollPic.js里有个cssFloat这个样式除ie外都支持就tmd ie不支持,解决方法改为styleFloat。这时会发现ie下正常了,但是其他浏览器却只滚动一次,解决思路,先用js判断浏览器类型,然后使用不同的样式:cssFloat或styleFloat。
代码如下: JSON序列化与解析(原生JS + Object对象拓展方法)【IE6和chrome测试通过】 var ele = { x:11, y:'string', z:{x:11, y:'string'} } toJSON = function(obj){ var arr = []; for(var key in obj){ var value = obj[key]; if(value == null){ value = ''; }else{ value = (typeof value === 'string' | typeof value === 'number') ? ('"' + value + '"') : toJSON(value); } var str = '"' + key + '":' + value;...
利用2个文件 ZeroClipboard.js ZeroClipboard.swf 代码如下: var clip = null; function $(id) { return document.getElementById(id); } function init(xm) { clip = new ZeroClipboard.Client(); clip.setHandCursor( true ); clip.addEventListener('load', function (client) { debugstr("Flash movie loaded and ready."); }); clip.addEventListener('mouseOver', function (client) { // update the text on mouse over ...
由于chrome,safari,opara 浏览器还未支持自动 "设为首页" & "加入收藏". 所以我们只能try, catch一下, 给个错误提示! 也算完美了. 另外ie中, 很多人也碰到过 它window.external.addFavorite. 时会报错的问题. 所以俺也只好抛出提示信息了. 加入收藏: 代码如下:function addFavorite(){ if (document.all){ try{ window.external.addFavorite(window.location.href,document.title); }catch(e){ ...
JavaScript获取Select当前值写法:var value = document.getElementById("select").options[document.getElementById("select").options.selectedIndex].value;var text = document.getElementById("select").options[document.getElementById("select").options.selectedIndex].text; 例子: 代码如下:function check() { var select = document.getElementById("select").options[document.getElementById("select").option...
代码如下: 图片旋转效果 与之间 ul{padding:0 15px;} ul li{padding-bottom:15px;border-bottom:1px dashed #EEE;} .caption{padding:15px 0 5px;} .caption input{margin-right:10px;padding:0 10px;} /* * www.byzuo.com * ok!: MSIE 6, 7, 8, Firefox 3.6, chrome 4, Safari 4, Opera 10 * o 旋转图片ID; * p 选择旋转方向,固定值为'left'或'right'; */ function rotate(o,p){ var img = document.getElementById(o)...
首先这里声明一下,关于我测试浏览器的版本是chrome15.0.874.121 Firefox 8.01 IE9 IETester 下面的代码关于声明 1:获得滚动条的情况 代码如下:function getScroll(){ var t, l, w, h; if (document.documentElement && document.documentElement.scrollTop) { t = document.documentElement.scrollTop;//滚动条的顶端 l = document.documentElement.scrollLeft;//滚动条的左端 w...
代码如下: ff 与 ie 动态加载元素的区别 li{margin:0;padding:0;list-style:none} function add(){ var liTemplate = $("#template"); liTemplate.find("input[name='awbpre']").val("999"); liTemplate.find("input[name='awbno']").val("12312311"); $("#box").append("" + liTemplate.html() + ""); } awbpre: awbno: 代码本意为:点击Add按钮时,动态向页面添加二个输入框,同时给二个新...
firefox 和 ie 的浏览器各自实现了input历史记录的功能,可以简化输入时的麻烦,但是,有时候弹出的下拉框会挡住页面显示内容,而且在某些情况下也不需要对input框进行记录,如号码查询的input框,用户不会对同一个号码进行多次查询,就没有必要让浏览器记录。 MSIE自定义了input 的扩展属性 autocomplete,置为off即可 用这个方法可以屏蔽MSIE,Firefox,chrome,opera则需要使用另一个扩展属性disableautocomplete 两扩展属性可...
问题描述: 当开发Chrome扩展时,页面的popup.html中需要js的时候,直接将JS写在动态绑定JS事件会提示: Refused to execute inline script because it violates the following Content Security Policy directive: “script-src ‘self' chrome-extension-resource:”.. 解决办法: 在popup.html中引用外部的js文件动态绑定JS事件,例如: 代码如下: test.js中: 代码如下: var listbox = document.getElementById("showlist"...
代码如下: function closeIt() { return "Any string value here forces a dialog box to \n" + "appear before closing the window."; } window.onbeforeunload = closeIt; Click here to navigate to www.gxlcms.com兼容FF,IE,Chrome的js离开或刷新页面检测,关键的部分是要有returnJavaScript教程/参考手册 JavaScript热搜 自定义vue组件发布到npm的方法Vue利用canvas实现移动端手写板的方法...