网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的范文:

 

标题 用JS读写注册表制作打印页面设置功能
范文
    <html>
    <head>
    <title>页面设置</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf8">
    <script language="javascript">
    var HKEY_Root,HKEY_Path,HKEY_Key;
    var HKEY_Root = "HKEY_CURRENT_USER";
    var HKEY_Path = " Explorer\\PageSetup\\";
    var HKEY_BASE = HKEY_Root + HKEY_Path;
    var Wsh = new ActiveXObject("WScript.Shell");
    function checkSubmit(){
    }
    //因为要调用组件来改写注册表,所改要把IE安全度调低一点
    //Internet选项-安全-自定义级别
    //特别ActiveX控件和插件那一栏,把禁用的改为提示
    //初始化页面数据
    function initData(){
    try{
    //document.getElementById"header").value = Wsh.RegRead(HKEY_BASE + "header"); //页眉
    //document.getElementById"footer").value = Wsh.RegRead(HKEY_BASE + "footer"); //页脚
    document.getElementById"margin_top").value = Wsh.RegRead(HKEY_BASE + "margin_top"); //上边距
    document.getElementById"margin_bottom").value = Wsh.RegRead(HKEY_BASE + "margin_bottom"); //下边距
    document.getElementById"margin_left").value = Wsh.RegRead(HKEY_BASE + "margin_left"); //左边距
    document.getElementById"margin_right").value = Wsh.RegRead(HKEY_BASE + "margin_right"); //右边距
    }catch(e){
    alert('不能进行页面设置,请降低IE安全级别!\nInternet选项-安全-自定义级别\n[ActiveX控件和插件]一栏,把所有(禁用)的改为(提示)');
    }
    }
    //保存数据
    function saveData(){
    try{
    Wsh.RegWrite(HKEY_BASE + "header","");
    Wsh.RegWrite(HKEY_BASE + "footer","");
    Wsh.RegWrite(HKEY_BASE + "margin_top","<%=Request("margin_top")%>"); //上边距
    Wsh.RegWrite(HKEY_BASE + "margin_bottom","<%=Request("margin_bottom")%>"); //下边距
    Wsh.RegWrite(HKEY_BASE + "margin_left","<%=Request("margin_left")%>"); //左边距
    Wsh.RegWrite(HKEY_BASE + "margin_right","<%=Request("margin_right")%>"); //右边距
    initData();
    alert('设置成功!');
    self.close();
    }
    catch(e){
    alert(e + "\n设置失败!");
    }
    }
    //页面加载事件
    function pageLoad(){
    if(sy_QueryString("action") == "SAVE"){
    saveData();
    return;
    }
    initData();
    }
    </script>
    </head>
    <body onload="pageLoad()">
    <form name="form1" method="post" action="PageSetup.asp?action=SAVE" onSubmit="return checkSubmit()" >
    <table valign="center" width="95%" cellspacing="0" cellpadding="0" bordercolor="#4a65a5">
    <tr>
    <td bgcolor="#4a65a5"><font color="#FFFFFF">页边距:</font></td>
    </tr>
    <tr>
    <td height="139">
    <table cellspacing="10" cellpadding="0" height="100%">
    <tr>
    <td height="99">
    <table cellspacing="0" cellpadding="0">
    <tr>
    <td height="1" bgcolor="#336699"></td>
    <td height="1" bgcolor="#336699"></td>
    </tr>
    <tr>
    <td bgcolor="#f5f5f5" height="3"> </td>
    <td bgcolor="#f5f5f5" height="3"> </td>
    </tr>
    <tr>
    <td bgcolor="#f5f5f5" height="2">上:</td>
    <td bgcolor="#f5f5f5">
    <input type="text" id="margin_top" name="margin_top" size="20" value=""></td>
    </tr>
    <tr>
    <td bgcolor="#f5f5f5" height="2">下:</td>
    <td bgcolor="#f5f5f5">
    <input type="text" id="margin_bottom" name="margin_bottom" size="20" value=""></td>
    </tr>
    <tr>
    <td bgcolor="#f5f5f5" height="2">左:</td>
    <td bgcolor="#f5f5f5">
    <input type="text" id="margin_left" name="margin_left" size="20" value=""></td>
    </tr>
    <tr>
    <td bgcolor="#f5f5f5" height="2">右:</td>
    <td bgcolor="#f5f5f5">
    <input type="text" id="margin_right" name="margin_right" size="20" value=""></td>
    </tr>
    <tr>
    <td height="80" bgcolor="#f5f5f5" colspan="2">
    <input type="submit" name="subOk" value=" 提 交 ">
    <input type="button" name="Submit3" value=" 取 消 " onClick="javascript:self.close();">
    &nbsp;&nbsp; </td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    <tr>
    <td bgcolor="#336699" height="3">
    </td>
    </tr>
    </table>
    </form>
    </body>
    </html>
随便看

 

在线学习网范文大全提供好词好句、学习总结、工作总结、演讲稿等写作素材及范文模板,是学习及工作的有利工具。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/12/16 3:24:04