javascript调用浏览器的功能
2007-08-22 17:25
357 查看
用window.print()可以调用打印对话框,那么页面设置和打印预览如何调用
<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0>
</OBJECT>
<input onclick=document.all.WebBrowser.ExecWB(1,1) type=button value=打开 name=Button1>
<input onclick=document.all.WebBrowser.ExecWB(4,1) type=button value=另存为 name=Button2>
<input onclick=document.all.WebBrowser.ExecWB(10,1) type=button value=属性 name=Button3>
<input onclick=document.all.WebBrowser.ExecWB(6,1) type=button value=打印 name=Button>
<input onclick=document.all.WebBrowser.ExecWB(8,1) type=button value=页面设置 name=Button4>
<input onclick=window.location.reload() type=button value=刷新 name=refresh>
<input onclick="window.external.ImportExportFavorites(true,'');" type=button value=导入收藏夹 name=Button5>
<input onclick="window.external.ImportExportFavorites(false,'');" type=button value=导出收藏夹 name=Button32>
<input onclick="window.external.AddFavorite(location.href, document.title)" type=button value=加入收藏夹 name=Button22>
<input type="button" onclick="document.all.WebBrowser.ExecWB(7,1)" value="打印预览">
=========================================================================
<html>
<head>
<title></title>
<script language="javascript">
function printsetup()
{
//打印页面设置
wb.execwb(8,1);
}
function printpreview()
{
//打印页面预览
wb.execwb(7,1);
}
function printit()
{
if (confirm('确定打印吗?'))
{
wb.execwb(6,1)
}
}
</script>
<script language=javascript>
//浮动帧打印
function fudong()
{
var odoc=window.document;
var r=odoc.body.createTextRange();
var stxt=r.htmlText;
alert(stxt)
var pwin=window.open("","print");
pwin.document.write(stxt);
pwin.print();
}
</script>
<script language="VBScript">
dim hkey_root,hkey_path,hkey_key
hkey_root="HKEY_CURRENT_USER"
hkey_path="/Software/Microsoft/Internet Explorer/PageSetup"
'//设置网页打印的页眉页脚为空
function pagesetup_null()
on error resume next
Set RegWsh = CreateObject("WScript.Shell")
hkey_key="/header"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,""
hkey_key="/footer"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,""
end function
'//设置网页打印的页眉页脚为默认值
function pagesetup_default()
on error resume next
Set RegWsh = CreateObject("WScript.Shell")
hkey_key="/header"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,"&w&b页码,&p/&P"
hkey_key="/footer"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,"&u&b&d"
end function
</script>
<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0>
</OBJECT>
<input onclick=document.all.WebBrowser.ExecWB(1,1) type=button value=打开 name=Button1>
<input onclick=document.all.WebBrowser.ExecWB(4,1) type=button value=另存为 name=Button2>
<input onclick=document.all.WebBrowser.ExecWB(10,1) type=button value=属性 name=Button3>
<input onclick=document.all.WebBrowser.ExecWB(6,1) type=button value=打印 name=Button>
<input onclick=document.all.WebBrowser.ExecWB(8,1) type=button value=页面设置 name=Button4>
<input onclick=window.location.reload() type=button value=刷新 name=refresh>
<input onclick="window.external.ImportExportFavorites(true,'');" type=button value=导入收藏夹 name=Button5>
<input onclick="window.external.ImportExportFavorites(false,'');" type=button value=导出收藏夹 name=Button32>
<input onclick="window.external.AddFavorite(location.href, document.title)" type=button value=加入收藏夹 name=Button22>
<input type="button" onclick="document.all.WebBrowser.ExecWB(7,1)" value="打印预览">
=========================================================================
<html>
<head>
<title></title>
<script language="javascript">
function printsetup()
{
//打印页面设置
wb.execwb(8,1);
}
function printpreview()
{
//打印页面预览
wb.execwb(7,1);
}
function printit()
{
if (confirm('确定打印吗?'))
{
wb.execwb(6,1)
}
}
</script>
<script language=javascript>
//浮动帧打印
function fudong()
{
var odoc=window.document;
var r=odoc.body.createTextRange();
var stxt=r.htmlText;
alert(stxt)
var pwin=window.open("","print");
pwin.document.write(stxt);
pwin.print();
}
</script>
<script language="VBScript">
dim hkey_root,hkey_path,hkey_key
hkey_root="HKEY_CURRENT_USER"
hkey_path="/Software/Microsoft/Internet Explorer/PageSetup"
'//设置网页打印的页眉页脚为空
function pagesetup_null()
on error resume next
Set RegWsh = CreateObject("WScript.Shell")
hkey_key="/header"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,""
hkey_key="/footer"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,""
end function
'//设置网页打印的页眉页脚为默认值
function pagesetup_default()
on error resume next
Set RegWsh = CreateObject("WScript.Shell")
hkey_key="/header"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,"&w&b页码,&p/&P"
hkey_key="/footer"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,"&u&b&d"
end function
</script>
相关文章推荐
- JavaScript调用浏览器打印功能
- 浏览器端javascript调用手机终端本地功能实现01-前言
- Flex中不使用FelxPrintJob通过ExternalInterface直接调用JavaScript利用浏览器本身的功能进行打印
- JavaScript调用浏览器打印功能实例分析
- 浏览器端javascript调用手机终端本地功能实现03-拍照
- Flex中不使用FelxPrintJob通过ExternalInterface直接调用JavaScript利用浏览器本身的功能进行打印
- JavaScript调用浏览器打印功能实例分析
- 浏览器端javascript调用手机终端本地功能实现02-功能点汇总
- javascript 兼容所有浏览器的DOM扩展功能
- 使用 Javascript 实现浏览器推送提醒功能的示例
- 用javascript判断不同的浏览器类型以调用不用的css
- javascript通过UIWebView调用功能
- 检查浏览器是否开启JavaScript功能代码
- 非常简单的兼容多浏览器Javascript实现分页功能
- Javascript屏蔽IE和Firefox浏览器默认按键响应(快捷键功能)
- javascript 复制功能 兼容所有浏览器的解决方案
- Silverlight和浏览器交互介绍----Silverlight中使用托管代码调用JavaScript
- 你要实现什么功能呢?javascript是在客户端浏览器环境中执行
- JavaScript 复制功能代码 兼容多浏览器
- JavaScript实现复制功能各浏览器支持情况实测