`
尘枉_yjava
  • 浏览: 71711 次
  • 性别: Icon_minigender_2
  • 来自: 北京
社区版块
存档分类
最新评论

js中一些指令!(摘抄)

阅读更多
一、【文件(F)】菜单中的命令的实现
  1、〖打开〗命令的实现
  [格式]:document.execCommand("open")
  [说明]这跟VB等编程设计中的webbrowser控件中的命令有些相似,大家也可依此琢磨琢磨。
  [举例]在<body></body>之间加入:
  打开
  2、〖使用 记事本 编辑〗命令的实现
  [格式]:location.replace("view-source:"+location)
  [说明]打开记事本,在记事本中显示该网页的源代码。
  [举例]在<body></body>之间加入:
  使用 记事本 编辑
  3、〖另存为〗命令的实现
  [格式]:document.execCommand("saveAs")
  [说明]将该网页保存到本地盘的其它目录!
  [举例]在<body></body>之间加入:
  另存为
  4、〖打印〗命令的实现
  [格式]:document.execCommand("print")
  [说明]当然,你必须装了打印机!
  [举例]在<body></body>之间加入:
  打印
  5、〖关闭〗命令的实现
  [格式]:window.close();return false
  [说明]将关闭本窗口。
  [举例]在<body></body>之间加入:
  关闭本窗口

  二、【编辑(E)】菜单中的命令的实现
  〖全选〗命令的实现
  [格式]:document.execCommand("selectAll")
  [说明]将选种网页中的全部内容!
  [举例]在<body></body>之间加入:
  全选

  三、【查看(V)】菜单中的命令的实现
  1、〖刷新〗命令的实现
  [格式]:location.reload() 或 history.go(0)
  [说明]浏览器重新打开本页。
  [举例]在<body></body>之间加入:
  刷新
  或加入:刷新
  2、〖源文件〗命令的实现
  [格式]:location.replace("view-source:"+location)
  [说明]查看该网页的源代码。
  [举例]在<body></body>之间加入:
  查看源文件
  3、〖全屏显示〗命令的实现
  [格式]:window.open(document.location,"url","fullscreen")
  [说明]全屏显示本页。
  [举例]在<body></body>之间加入:
  全屏显示

  四、【收藏(A)】菜单中的命令的实现
  1、〖添加到收藏夹〗命令的实现
  [格式]:window.external.AddFavorite('url', '“网站名”)
  [说明]将本页添加到收藏夹。
  [举例]在<body></body>之间加入:
  [url=Java script:window.external.AddFavorite('http://oh.jilinfarm.com', '胡明新的个人主页')]添加到收藏夹[/url]
  2、〖整理收藏夹〗命令的实现
  [格式]:window.external.showBrowserUI("OrganizeFavorites",null)
  [说明]打开整理收藏夹对话框。
  [举例]在<body></body>之间加入:
  整理收藏夹

  五、【工具(T)】菜单中的命令的实现
  〖internet选项〗命令的实现
  [格式]:window.external.showBrowserUI("PrivacySettings",null)
  [说明]打开internet选项对话框。
  [举例]在<body></body>之间加入:
  internet选项

  六、【工具栏】中的命令的实现
  1、〖前进〗命令的实现
  [格式]history.go(1) 或 history.forward()
  [说明]浏览器打开后一个页面。
  [举例]在<body></body>之间加入:
  前进
  或加入:前进
  2、〖后退〗命令的实现
  [格式]:history.go(-1) 或 history.back()
  [说明]浏览器返回上一个已浏览的页面。
  [举例]在<body></body>之间加入:
  后退
  或加入:后退
  3、〖刷新〗命令的实现
  [格式]:document.reload() 或 history.go(0)
  [说明]浏览器重新打开本页。
  [举例]在<body></body>之间加入:
  刷新
  或加入:刷新
  
  七、其它命令的实现
  〖定时关闭本窗口〗命令的实现
  [格式]:settimeout(window.close(),关闭的时间)
  [说明]将关闭本窗口。
  [举例]在<body></body>之间加入:
  3秒关闭本窗口

  如果大家还整理出其他用javascript实现的命令,不妨投稿来和大家分享。
  【附】为了方便读者,下面将列出所有实例代码,你可以把它们放到一个html文件中,然后预览效果。
  打开<br>
  使用 记事本 编辑<br>
  另存为<br>
  打印<br>
  关闭本窗口<br>
  全选<br>
  刷新 刷新<br>
  查看源文件 <br>
  全屏显示 <br>
  [url=Java script:window.external.AddFavorite('http://homepage.yesky.com', '天极网页陶吧')]添加到收藏夹[/url] <br>
  整理收藏夹 <br>
  internet选项 <br>
  前进1 前进2<br>
  后退1 后退2<br>
  3秒关闭本窗口<br>
"打开,另存为,属性,打印"等14个JS代码
http://www.weiw.com  2003-8-19  伟网动力


■打开■
<input name=Button onClick=document.all.WebBrowser.ExecWB(1,1) type=button value=打开>
<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
■另存为■
<input name=Button onClick=document.all.WebBrowser.ExecWB(4,1) type=button value=另存为><OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
■属性■
<input name=Button onClick=document.all.WebBrowser.ExecWB(10,1) type=button value=属性><OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
■打印■
<input name=Button onClick=document.all.WebBrowser.ExecWB(6,1) type=button value=打印><OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
■页面设置■
<input name=Button onClick=document.all.WebBrowser.ExecWB(8,1) type=button value=页面设置><OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0></OBJECT>
■刷新■
<input type=button value=刷新 name=refresh onclick="window.location.reload()">
■导入收藏■
<input type="button" name="Button" value="导入收藏夹" onClick=window.external.ImportExportFavorites(true,);>
■导出收藏■
<input type="button" name="Button3" value="导出收藏夹" onClick=window.external.ImportExportFavorites(false,);>
■加入收藏■
<INPUT name=Button2 onclick="window.external.AddFavorite(location.href, document.title)" type=button value=加入收藏夹>
■整理收藏夹■
<INPUT name=Submit2 onclick="window.external.ShowBrowserUI(OrganizeFavorites, null)" type=button value=整理收藏夹>
■查看原文件■
<INPUT name=Button onclick=window.location = "view-source:" + window.location.href type=button value=查看源文件>
■语言设置■
<INPUT name=Button onclick="window.external.ShowBrowserUI(LanguageDialog, null)" type=button value=语言设置>
■前进■
<INPUT name=Submit onclick=history.go(1) type=submit value=前进>
■后退■
<INPUT name=Submit2 onclick=history.go(-1) type=submit value=后退>

0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics