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...
IE:var obj=document.elementFromPoint(event.clientX,event.clientY); 获取对象文本var a=obj.innerText FF里面要在事件里面添加对象才可以读取坐标。 HTML:onclick="gj(event)" JS: 代码如下:function gj(event){ var b=objobj=document.elementFromPoint(event.clientX,event.clientY);}
代码如下:输出,结果是:site=popasp alert(r); //根据得到的结果可以使用 var pName = r.split("=")[0]; //获取参数名 var pValue = r.split("=")[1]; //获取参数值 //测试输出: alert("参数名:" + pName + "\n\n" + "参数值:" + pValue); //其他实际应用: //可以根据需要,配合以下方法实现自己要实现的功能; //var hostname = location.hostname; //获取当前域名(不包含http...
JavaScript 获取客户端计算机硬件及系统信息 通过WMI来实现获取客户端计算机硬件及系统信息: 代码如下: function getSysInfo(){ var locator = new ActiveXObject ("WbemScripting.SWbemLocator"); var service = locator.ConnectServer("."); //CPU信息 var cpu = new Enumerator (service.ExecQuery("SELECT * FROM Win32_Processor")).item(); var cpuType=cpu.Name,hostName=cpu.SystemName; //内存信息 var memory = new Enu...
在新定义出来的标准下 document.documentElement.clientHeight在IE和火狐里都能获取正确值,下面一篇文章详细介绍了获取各种浏览器可见窗口大小这方面的差别: function getInfo(){ var s = ""; s += " 网页可见区域宽:"+ document.body.clientWidth; s += " 网页可见区域高:"+ document.body.clientHeight; s += " 网页可见区域宽:"+ document.body.offsetWidth + " (包括边线和滚动条的宽)"; s += " 网页可见区...
代码如下:javascript_获取网页标题代码function get_pagetitle(split_chr,new_pagetit){ var titleitems,return_title; var the_pagetitle=document.title; titleitems=the_pagetitle.split(split_chr); return_title=the_pagetitle; if(titleitems[1]) { return_title=the_pagetitle.replace(titleitems[1],new_pagetit) } else { if(new_pagetit) { return_title=the_pagetitle & split_chr & new_pagetit; } } alert(retu...
代码如下: function getRootPath(){ var strFullPath=window.document.location.href; var strPath=window.document.location.pathname; var pos=strFullPath.indexOf(strPath); var prePath=strFullPath.substring(0,pos); var postPath=strPath.substring(0,strPath.substr(1).indexOf(‘/')+1); return(prePath+postPath); } var webpath=getRootPath(); //webpath就是目录路径变量 JavaScript教程/参考手册 Java...
IE方法:document.frames['myFrame'].document.getElementById('test').value; 火狐方法:document.getElementById(myFrame).contentWindow.document.getElementById(test).value; IE、火狐方法: 代码如下: function getValue(){var tmp = ;if(document.frames){tmp += ie哥说:;tmp += document.frames[myFrame].document.getElementById(test).value;}else{tmp = document.getElementById(myFrame).contentWindow.document.g...
//获取form对象 var form=document.getElementById(‘my_form); //用户名input对象 user_name是对象的name属性 var userName=form.user_name; //用户名清空 userName.value=‘; //用户密码input对象 password是对象的name属性 var password=form.password; //用户密码清空 password.value=”;
JavaScript如何获取当前页面上的指定对象. 方法如下: 代码如下: document.getElementById(ID) //获得指定ID值的对象 document.getElementsByName(Name) //获得指定Name值的对象数组 document.all[] //很智能的东东 不过非WEB标准 document.getElementsByTagName //获得指定标签值的对象数组 下面给出例子,只需把注释去掉直接运行就可看出效果. 代码如下: New Document
Hot.xml文件 : 代码如下: 刘亦菲 MingXing/LiuYiFei.htm red 蔡依林 MingXing/CaiYiLin.htm blue 张娜拉 MingXing/ZhangNaLa.htm green 张韶涵 MingXiang/ZhangShaoHan.htm grey 张靓颖 MingXing/ZhangLiangYin.htm black 李宇春 MingXing/LiYuChun.htm yellow 徐若瑄 MingXing/XuLuXuan.htm pink demo1.html文件: JavaScript获取XML数据 代码如下: var xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); ...
代码如下:function getExplorerInfo() { var explorer = window.navigator.userAgent.toLowerCase() ; //ie if (explorer.indexOf("msie") >= 0) { var ver=explorer.match(/msie ([\d.]+)/)[1]; return {type:"IE",version:ver}; } //firefox else if (explorer.indexOf("firefox") >= 0) { var ver=explorer.match(/firefox\/([\d.]+)/)[1]; return {type:"Firefox",version:ver}; } //Chrome else if(explorer.in...
一、获取函数名称的3种实现方法实例1: 在js权威指南中看到的一个方法: Function.prototype.getName = function(){ return this.name || this.toString().match(/function\s*([^(]*)\(/)[1]} 实例2: 如果当前函数是有名函数,则返回其名字,如果是匿名函数则返回被赋值的函数变量名,如果是闭包中匿名函数则返回“anonymous”。 代码如下: var getFnName = function(callee){ var _callee = callee.toString().repla...
关于js获取flash对象,网上有非常多的例子,我也尝试了不少方法。 虽然都能用,但是没有我最想要的东西, 后来看了下百度的,虽然很规范,各种情况都考虑到了,但是代码量却不是不容乐观, 前前后后将近20行代码,压缩后也有 864 个字节。 所以本文诞生了。 我想测试并分享下网上收集的几种我比较满意的方法。 也顺便请大家帮忙测试下兼容性,有不兼容的在下面留个言,最好写上浏览器版本,这样我也好测试并修复代码。 下面来看代码...
从Mozilla Aurora 11起,火狐浏览器里实现了一些新功能,其中一个就是对电池状态接口的基本实现。这个很简单的接口能提供你关于电池当前电量,是否在充电等信息,以及一些电池状态变化事件。让我们来看看效果! 电池对象是存放在window.navigator.battery里,但因为这是火狐浏览器首次实现并提供这个接口,并未普及,你需要使用window.navigator.mozBattery这种写法。这个mozBattery对象有下列属性: 1.charging: 表示当前电池设备...