1,js操作剪贴板
<html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>标题页</title> <script language="javascript"> function windowCopy(){ window.clipboardData.setData("Text",txt1.innerText); } function windowParse(){ var txt= window.clipboardData.getData("Text"); txt1.innerText=txt+"粘贴完毕" } </script> </head> <body> <textarea cols=30 rows=10 id="txt1"> </textarea> <table id="mytbl" width="300" height="50" border="0" cellspacing="2" cellpadding="0" bgcolor="#FFb609"> <tr> <td> <input id="Button1" type="button" value="window剪贴板-剪切" onclick="windowCopy()" /></td> <td> <input id="Button1" type="button" value="window剪贴板-粘贴" onclick="windowParse()" /></td> </tr> </table> </body> </html>
2,js打开硬盘驱动器
<html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>标题页</title> </head> <body> <form action="file:///c|/"><input type="submit" value="打开C盘"></form> <form action="file:///d|/"><input type="submit" value="打开D盘"></form> <form action="file:///e|/"><input type="submit" value="打开E盘"></form> </body> </html>
3,js 加入收藏夹
<html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>标题页</title> </head> <body> <span style="CURSOR: hand" onClick="window.external.addFavorite('http://www.google.com','最爱的搜索')" title="Google搜索">收藏搜索网站</span> </body> </html>
4,js 复制网址和标题
<html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>标题页</title> </head> <body> <input type="button" name="Submit" onClick='toClipBoard()' value="复制网址,传给好友"> <script language="javascript"> function toClipBoard() { var clipBoardContent=""; clipBoardContent+=document.title; //获取页面标题 clipBoardContent+="\n"; clipBoardContent+=this.location.href; //获取页面地址 //将拷贝内容存放到剪贴板中 window.clipboardData.setData("Text",clipBoardContent); alert("复制成功,可以粘贴到你的QQ/MSN上,推荐给你的好友!"); } </script> </body> </html>
5,js 关闭输入法
<input id="txtname" style="ime-mode:disabled">
6,js 获取浏览器版本信息
<html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>无标题页</title> <script language="JavaScript"> document.write("浏览器名称: "+navigator.appName+"<br>"); document.write("浏览器版本号: "+navigator.appVersion+"<br>"); document.write("系统语言: "+navigator.systemLanguage+"<br>"); document.write("系统平台: "+navigator.platform+"<br>"); document.write("浏览器是否支持cookie: "+navigator.cookieEnabled+"<br>"); </script> </head> <body > <div>以上是浏览器的检测信息/div> </body> </html>
7,js 显示本地计算机信息
<html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>标题页</title> <script language="javascript"> var WshNetwork = new ActiveXObject("WScript.Network"); //创建 alert("用户域: " + WshNetwork.UserDomain); //显示用户所在的域 alert("计算机名称: " + WshNetwork.ComputerName); //显示计算机名 alert("用户名: " + WshNetwork.UserName); //显示登录用户名 </script> </head> <body > </body> </html>
8,ie 文件菜单中的打开命令,和选项命令
<html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>标题页</title> </head> <body> <a href="#" onclick=document.execCommand("open")>打开</a> <a href="#" onclick=window.external.showBrowserUI("PrivacySettings",null)>internet选项</a> </body> </html>
9,js 弹出保存对话框
<html> <iframe src="" width="0" height="0" id="myIframe" name="myIframe"></iframe> <textarea id="content" rows="6" cols="50"></textarea> <P> <button onclick="javascript:saveFile()">保存</button> <script language="javascript"> function saveFile(){ var obj = window.frames("myIframe"); //找到窗体上的iframe obj.document.open(); //打开iframe obj.document.write (document.getElementById("content").value); //获取文档的内容 obj.document.close(); //关闭iframe obj.document.execCommand("SaveAs"); //调用保存对话框 } </script> </html>
10,js 执行客户端可执行程序
<html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>标题页</title> <script language="javascript"> function exec (command) { window.oldOnError = window.onerror; //错误处理的默认事件 window._command = command; //要执行的命令 window.onerror = function (err) { //重新设置错误处理事件 if (err.indexOf('Automation') != -1) { //如果因权限问题被终止 alert('命令已经被用户禁止!'); return true; } else return false; } var wsh = new ActiveXObject('WScript.Shell');//创建可执行应用程序对象 if (wsh) wsh.Run(command); //执行指定的命令 window.onerror = window.oldOnError; //恢复默认的错误处理事件 } </script> </head> <body> <a href="#" onclick="exec('C:/NTDETECT.COM')">执行文件</a> </body> </html>
11,js 自动调用Outlook发送邮件
<html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>标题页</title> </head> <body> <a href="mailto:cguanjun@tom.com?subject=测试邮件&body=这是一封测试的邮件"> 发送邮件</a> </body> </html>
12,js 弹出颜色选择窗口
<html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>标题页</title> <script language="javascript"> function getColor(color) { var sInitColor = color; //获取参数传递的颜色 if (sInitColor == null||sInitColor=="") var sColor = myColor.ChooseColorDlg(); //打开颜色对话框 else var sColor = myColor.ChooseColorDlg(sInitColor);//设置颜色 sColor = sColor.toString(16); //转换为16进制颜色 if (sColor.length < 6) { //如果颜色小于6位 var sTempString = "000000".substring(0,6-sColor.length);//格式化为6位 sColor = sTempString.concat(sColor); } sColor = "#" + sColor; //添加颜色标签 return sColor; } </script> </head> <body> <input type=text name="txt1" value="这里显示最终调用的颜色"> <input type=button value="选取颜色" onClick="txt1.value=getColor()"> <OBJECT id=myColor CLASSID="clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b" width="0px" height="0px"></OBJECT> </body> </html>
13,js 查看用户是否安装了flash插件
<HTML> <head> <title>无标题</title> </head> <BODY> <body> <SCRIPT LANGUAGE="JavaScript"> var swf = new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); //创建AcitiveXObject组件 (swf) ? document.writeln('你已经安装了插件') : document.writeln('你没有安装插件'); //判断组件的值 </SCRIPT> </body> </HTML>