代码如下:< 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的键盘上一张下一张
jsp代码: 代码如下:<form id="search"> <select id="jobSelect" style="width: 200px;" name="jobSelect"> <s:if test='jobSelect == null || jobSelect == ""'> <option selected="selected" value="-1">--依职类筛选--</option> </s:if> <s:else> <option value="-1">--依职类筛选--</option> </s:else> <s:iterator value="jobCat" status="s"> <s:if test="jobSelect == catKey"> <option value="<s:property v...
以下是 我在开发中遇到的情况: 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...
首先这里声明一下,关于我测试浏览器的版本是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...
代码如下:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>图片旋转效果</title> <meta http-equiv="content-type" content="text/html;charset=gb2312"> <!--把下面代码加到<head>与</head>之间--> <style type="text/css"> ul{padding:0 15px;} ul li{padding-bottom:15px;border-bott...
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; 例子: 代码如下:<script>function check() { var select = document.getElementById("select").options[document.getElementById("select"...
HTML元素,属性已经十分丰富了。但是,在某些场合下,也会显得捉襟见肘,这时候自定义属性就发挥了十分关键的作用。 Html元素的自定义属性,使用起来,十分方便,例如: <input type=”button” value=”Click Me, Baby!” /> 假设我们现在需要限制,这个按钮,只能点击2次,然后就失效了。 通常的实现方式,是可以利用全局变量的形式来记录点击次数,但我们这里用自定义属性来实现这个功能,展示一下自定义属性的优势;我们对上面...
现在的浏览器大概有好几种,各个人的喜好也不同,所以也就用着不同的浏览器!我们开发的人来说经常要加个判断,要不可能某些功能没法正常使用。要是没加个判断就会给大家带来些麻烦!虽然可能大家的喜好不同!用的系统也不同!有人喜欢用ie, firefox,还有人喜欢用腾讯tt,maxthon等等。虽然名字可能有很多种,但是内核我们知道下就没问题了。如IE内核的:IE,maxthon,tt都是。当然还有netscape内核!看大家怎么去判断! 由于在开发时碰上这...
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...
代码如下:<!doctype html public "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="Keywords" content="YES!B/S!" /><meta name="Description" content="This page is from http://Justinyoung.cnblogs.com" /><title>CSS/Javascript demo</title><...
由于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){ ...
代码如下:document.onkeydown=function(e){ var e=window.event||e; var element=e.srcElement||e.target; if(e.keyCode==13&&element.type!="submit"&&element.type!="button"&&element.type!="textarea"&&element.type!="reset"){ if(document.all){ e.keyCode=9; }else{ getNextInput(element).focus(); e.preventDefault(); } }}function getNextInput(inp...
用uchome普通上传来举例,取原代码:return obj.files.item(0).getAsDataURL(); 升级到Firefox7.0后,需要改为:return window.URL.createObjectURL(obj.files[0]); 实际上就是Firefox7.0废弃了item属性。
当我们需要动态生成DOM对象的时候,会使用createElement的方法创建。但是在IE和Firefox下,createElement方法是有差异的。 在 IE 中,可以使用以下两种方式来创建一个元素: 1、document.createElement(table) 2、document.createElement(<table border="0">) 而在 Firefox 只支持: document.createElement(table) 同时,如果添加属性和事件的话,需要使用setAttribute方法 示例: 代码如下:if($.browser.msie){ var rowHtml = <...
代码如下:<body> <input type=file id="j" onchange="getValue();" style="-moz-opacity:0;filter:alpha(opacity=0);opacity:0;position:absolute;left:166px;" /> <input id="ye" style="color: green;border: 1px solid green;width:300px;" /> <input type="button" value="File" style="border: 1px solid green;width:80px;" /> </body> <script language="javascript"> function getValue(){ document.getElementById(ye).va...