javascript 技巧
//自带的打印预览 WebBrowser.ExecWB(1,1) 打开
Web.ExecWB(2,1) 关闭现在所有的IE窗口,并打开一个新窗口
Web.ExecWB(4,1) 保存网页
Web.ExecWB(6,1) 打印
Web.ExecWB(7,1) 打印预览
Web.ExecWB(8,1) 打印页面设置
Web.ExecWB(10,1) 查看页面属性
Web.ExecWB(15,1) 好像是撤销,有待确认
Web.ExecWB(17,1) 全选
Web.ExecWB(22,1) 刷新
Web.ExecWB(45,1) 关闭窗体无提示
<style media=print>
.Noprint{display:none;}<!--用本样式在打印时隐藏非打印项目-->
.PageNext{page-break-after: always;}<!--控制分页-->
</style>
<object id="WebBrowser" width=0 height=0 classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">
</object>
<center class="Noprint" >
<input type=button value=打印 onclick=document.all.WebBrowser.ExecWB(6,1)>
<input type=button value=直接打印 onclick=document.all.WebBrowser.ExecWB(6,6)>
<input type=button value=页面设置 onclick=document.all.WebBrowser.ExecWB(8,1)>
</p>
<p> <input type=button value=打印预览 onclick=document.all.WebBrowser.ExecWB(7,1)>
</center>
//去掉打印时的页眉页脚
<script language="JavaScript">
var HKEY_Root,HKEY_Path,HKEY_Key;
HKEY_Root="HKEY_CURRENT_USER";
HKEY_Path="[url=file://Software//Microsoft//Internet]\\Software\\Microsoft\\Internet[/url] Explorer\\PageSetup\\";
//设置网页打印的页眉页脚为空
function PageSetup_Null()
{
try
{
var Wsh=new ActiveXObject("WScript.Shell");
HKEY_Key="header";
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");
HKEY_Key="footer";
Wsh.RegWrite(H
相关文档:
根据浏览器复制到剪贴板的功能,具体代码如下:
var txt="要复制到剪贴板的内容";
function copyToClipboard(txt) {
if(window.clipboardData) {
window.clipboardData.clearData();
&nb ......
1.
(function(){
return typeof arguments;
})();
“object”
“array”
“arguments”
“undefined”
2.   ......
最近,我参考,根据正则表达式构建DFA(确定的有穷自动机)的技术,完成了一个从正则表达式到JavaScript的翻译器。
翻译器是针对chrome和firefox设计的,没有在其他浏览器中测试过。
Google Code上的源代码:http://code.google.com/p/nephotools/source/browse/#svn/trunk/regexpQuery
regexpQuery.js中定义了regexpQue ......
我们知道,javascript在执行期时是由内到外执行脚本的,那么离我们的脚本最远的全局对象,很可能要跨越几层作用域对能访问到它。不过在IE中,从最内层到最外层要花的时间比其他多出很多。加之,javascript是一种胶水语言,它必须要调用DOM对能完成我们大多数选择。最著名的就是选择元素(document.getElementById,documen ......
定义变量
var test=10;
使用对象属性
可以使用 . 操作符获得属性,也可以使用数组下标获得,比如
for(var prop in document)
document.write(document[prop]+"<br>");
With 声明对象,之后再用到对象就不必声明了
with(document){
write("Hello World<br>标题: ");
write(title);
}
常用对象 ......