用uchome普通上传来举例,取原代码:return obj.files.item(0).getAsDataURL(); 升级到Firefox7.0后,需要改为:return window.URL.createObjectURL(obj.files[0]); 实际上就是Firefox7.0废弃了item属性。
由于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){ ...
现在的浏览器大概有好几种,各个人的喜好也不同,所以也就用着不同的浏览器!我们开发的人来说经常要加个判断,要不可能某些功能没法正常使用。要是没加个判断就会给大家带来些麻烦!虽然可能大家的喜好不同!用的系统也不同!有人喜欢用ie, firefox,还有人喜欢用腾讯tt,maxthon等等。虽然名字可能有很多种,但是内核我们知道下就没问题了。如IE内核的:IE,maxthon,tt都是。当然还有netscape内核!看大家怎么去判断! 由于在开发时碰上这...
代码如下:CSS/Javascript demo function test(){ copyToClipboard("dddd"); } copyToClipboard = function(txt) {if(window.clipboardData) { window.clipboardData.clearData(); window.clipboardData.setData("Text", txt);} else if(navigator.userAgent.indexOf("Opera") != -1) {window.location = txt;} else if (window.netscape) {try {netscape.security.PrivilegeManager.enablePrivilege("Universa...
HTML元素,属性已经十分丰富了。但是,在某些场合下,也会显得捉襟见肘,这时候自定义属性就发挥了十分关键的作用。 Html元素的自定义属性,使用起来,十分方便,例如: <input type=”button” value=”Click Me, Baby!” /> 假设我们现在需要限制,这个按钮,只能点击2次,然后就失效了。 通常的实现方式,是可以利用全局变量的形式来记录点击次数,但我们这里用自定义属性来实现这个功能,展示一下自定义属性的优势;我们对上面...
window.event IE:有window.event对象 FF:没有window.event对象。可以通过给函数的参数传递event对象。如onmousemove=doMouseMove(event) 鼠标当前坐标 IE:event.x和event.y。 FF:event.pageX和event.pageY。 通用:两者都有event.clientX和event.clientY属性。 鼠标当前坐标(加上滚动条滚过的距离) IE:event.offsetX和event.offsetY。 FF:event.layerX和event.layerY。 标签的x和y的坐标位置:style.posLeft 和 style.posTop...
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...
以下是 我在开发中遇到的情况: 1、动态删除table里的某一行。 table:表示table对象。 k:表示行号 table.rows[k].removeNode(true); //firefox执行失败,ie执行成功 IE与FireFox兼容写法 table.deleteRow(k); 2、为HTML标签自定义属性。 inputElement:表示表单元素。 propertyName:表示表单元素下的某个属性 inputElement.propertyName; //firefox执行失败,ie执行成功 IE与FireFox兼容写法 document.getElementById("txtInput...
jsp代码: 代码如下:js代码: 代码如下: validate = function(){ var jobSelect; var areaSelect; var search = document.getElementById("search"); for(var i=0;i if(search.jobSelect[i].selected){ jobSelect = search.jobSelect[i].value; } } for(var i=0;i if(search.areaSelect[i].selected){ areaSelect = search.areaSelect[i].value; } } if(jobSelect == -1 && areaSelect == -1){ document.g...
代码如下: < script language = "javascript" > document.onkeydown = chang_page; function chang_page(event) { var event = event ? event : (window.event ? window.event : null); var key = event.keyCode || event.which; if (key == 37 || key == 33) location = ; if (key == 39 || key == 34) location = ; } < / script > 兼容IE,google,firefox的键盘上一张下一张
在项目中运用到了JQUERY UI,用到了其中的disableSelection()方法,这个方法是让页面上的指定元素无法通过鼠标拖拽进行选择。 由于某些需求,我在给div使用了此方法后,达到了上述效果,但是有不足的地方。 在Firefox下运用此方法后,div中的select方法点击之后将会无法弹出,在IE和CHROME下没有此现象。
firefox不支持iframe的onreadystatechange事件,这个让我调试一下下午。。。 直接贴代码 我这里想做的效果是先生成一个iframe,当我想里面加载内容的时候触发这个事件, 代码可以很清晰的看到用onload方法来进行替代了。
代码如下: (function() { if (window.FileUpload) { return; } window.FileUpload = function (id, url) { this.id = id; this.autoUpload = true; this.url = url; this.maxSize = null; this.extensions = null; this.dropId = null; }; window.FileUpload.prototype.init = function() { var obj = this; $(# + this.id).change(function () { if (obj.autoUpload) { obj.upload(); } }); if (this.supportsFormData()) { if (t...