★★ 在网页中调用IE的内部命令 ★★
在网页中调用IE的内部命令
【孟宪会之精彩世界】 http://go.163.com/colorweb
在IE4+的网页中,使用IE的内部命令,可以实现一些常用的命令:如打印、刷新等。语法如下:
bSuccess = object.execCommand(sCommand [, bUserInterface] [, vValue])
其中:bSuccess是返回值:true 或 false
sCommand是命令字符串。
bUserInterface是可选项,true 或 false。
vValue是可选项,是逻辑值,数字、字符串等[根据命令类型而定]。
<SCRIPT>
function test(){
if(document.queryCommandSupported('Print'))
alert("支持Print命令!")
else
alert("不支持Print命令!")
}
</SCRIPT>
<INPUT onclick=test() type=button value=测试是否支持该命令><BR><BR><INPUT onclick="document.execCommand('print',false,0)" 
type=button value=打印><BR><INPUT onclick="document.execCommand('SelectAll',false,null)" type=button value=全选><BR><INPUT 
onclick="document.execCommand('Refresh',false,null)" type=button value=刷新本页><BR><INPUT onclick="document.execCommand
('SaveAs',true,'c:\\index.txt')" type=button value=另存为[指定文件名和路径]><BR><INPUT onclick="document.execCommand
('SaveAs')" type=button value=另存为[不指定文件名和路径]><BR><INPUT onclick="document.execCommand('Unselect',false,null)" 
type=button value=不选[请选定页面上的文字然后按这里]><BR><INPUT onclick="document.execCommand('delete',false,null)" 
type=button value=删除[请选定页面上的文字然后按这里]><BR></BLOCKQUOTE></BLOCKQUOTE>本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/net_lover/archive/2001/06/12/6858.aspx


浙公网安备 33010602011771号