积极答复者
如何编程实现设置页边距?

问题
-
我想通过程序的方式在WEB下实现自定义面边距,使用了“margin_left”没有成功,请大侠们指点一下好吗?
youl- 已移动 Sheng Jiang 蒋晟 2009年12月19日 4:42 客户端HTML问题 (发件人:ASP.NET 与 AJAX)
答案
-
可以了,但没有还没有研究和上面的代码有什么区别!
<script language="JavaScript" type="text/javascript">
var HKEY_Root, HKEY_Path, HKEY_Key;
HKEY_Root = "HKEY_CURRENT_USER";
HKEY_Path = "\\Software\\Microsoft\\Internet 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(HKEY_Root + HKEY_Path + HKEY_Key, "");
HKEY_Key = "margin_bottom";
Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "0");
HKEY_Key = "margin_left";
Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "0");
HKEY_Key = "margin_right";
Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "0");
HKEY_Key = "margin_top";
Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "0");
}
catch (e) {
//alert(e);
}
}
//设置网页打印的页眉页脚为默认值
function PageSetup_Default() {
try {
var Wsh = new ActiveXObject("WScript.Shell");
HKEY_Key = "header";
Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "&w&b页码,&p/&P");
HKEY_Key = "footer";
Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "&u&b&d");
}
catch (e) { }
}
</script>
youl- 已标记为答案 youer3 2009年12月18日 7:35
全部回复
-
是margin-left 不是margin_left哈
Wenn ich dich hab’,gibt es nichts, was unerträglich ist.坚持不懈!My blog~~~ -
大侠,在注册表里就是“margin_left”,并且可以设置页边距,但是这样却不行:
<script language="JScript">
var hkey_root,hkey_path,hkey_key
hkey_root="HKEY_CURRENT_USER"
hkey_path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\"
//设置网页打印的页眉页脚为空
function pagesetup_null()
{
try{
var RegWsh = new ActiveXObject("WScript.Shell")
hkey_key="header"
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"")
hkey_key="footer"
RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "")
hekey_key = "margin_left"
RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "10")
}catch(e){alert(e.name+" "+e.message)}
}
//设置网页打印的页眉页脚为默认值
function pagesetup_default()
{
try{
var RegWsh = new ActiveXObject("WScript.Shell")
hkey_key="header"
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"这是自定义")
hkey_key="footer"
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&u&b&d")
}catch(e){alert(e.name+" "+e.message)}
}
</script>
youl -
可以了,但没有还没有研究和上面的代码有什么区别!
<script language="JavaScript" type="text/javascript">
var HKEY_Root, HKEY_Path, HKEY_Key;
HKEY_Root = "HKEY_CURRENT_USER";
HKEY_Path = "\\Software\\Microsoft\\Internet 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(HKEY_Root + HKEY_Path + HKEY_Key, "");
HKEY_Key = "margin_bottom";
Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "0");
HKEY_Key = "margin_left";
Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "0");
HKEY_Key = "margin_right";
Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "0");
HKEY_Key = "margin_top";
Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "0");
}
catch (e) {
//alert(e);
}
}
//设置网页打印的页眉页脚为默认值
function PageSetup_Default() {
try {
var Wsh = new ActiveXObject("WScript.Shell");
HKEY_Key = "header";
Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "&w&b页码,&p/&P");
HKEY_Key = "footer";
Wsh.RegWrite(HKEY_Root + HKEY_Path + HKEY_Key, "&u&b&d");
}
catch (e) { }
}
</script>
youl- 已标记为答案 youer3 2009年12月18日 7:35