|
藍森林 http://www.lslnet.com 2006年8月25日 8:28
求救,關於連接到新窗口頁面邊距的問題
我做的效果是點擊圖片,就會出現一個新窗口,因為新窗口直接連接的是圖片,所以DW自動生成的這個新窗口都是有頁邊距的,怎麼能把頁邊距設為0呢
被點擊的圖片代碼
<input type="image" img src="grave/s/grave-1.jpg" onClick="window.open('grave/grave-1.jpg', 'Sample','style=margin-top: 0px,''toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=505,height=323,left=200,top=150')" name="Input50">
是不是要加margin-left: 0px之類的代碼,加到哪呢,謝謝各位了! :confused: |
<input type="image" img src="images/index_01.gif" onClick="var bbb=window.open('images/index_01.gif', 'Sample','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=505,height=323,left=200,top=150');bbb.document.body.style.margin='110px';" name="Input50"> |
謝謝樓上的,可是不管用啊 |
[html]
<script language=JavaScript>
function openWin()
{
newWin = window.open("","",
"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=505,height=323 top=100 left=200");
newWin.document.writeln("<html>")
newWin.document.writeln("<head>")
newWin.document.writeln("<title>新窗口<\/title>")
newWin.document.writeln("<style type=\'text/css\'>")
newWin.document.writeln("body {margin-top: 0px;")
newWin.document.writeln("}")
newWin.document.writeln("<\/style>")
newWin.document.writeln("<\/head>")
newWin.document.writeln("<body>")
newWin.document.writeln("<img src=\'grave.jpg\' width=450,height=280 alt=\'這是第2張圖片\' align=\'left\' valign=\'top\'>")
newWin.document.writeln("<\/body>")
newWin.document.writeln("<\/html>")
}
</script>
<a href="javascript:openWin()"><img src="grave/s/grave.jpg" alt="這是第一張圖片"></a>[/html]
|
謝謝樓上的,可是這樣插一個圖太煩瑣了,還是謝謝兩位了 |
helmsman在上個帖子中說
請問如果我想控制彈出圖片的窗口的大小如何實現呢,謝謝. |
[html]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>demo</title>
<script type="text/JavaScript">
<!--
function JustSoPicWindow(imageName,imageWidth,imageHeight,alt,bgcolor,hugger) {
// by E Michael Brandt of ValleyWebDesigns.com - Please leave this comment intact.
alt=alt+" ** Click window to close **"
if (bgcolor=="") {
bgcolor="#FFFFFF";
}
var adj=10
var w = screen.width;
var h = screen.height;
var byFactor=1;
if(w<740){
var lift=0.90;
}
if(w>=740 & w<835){
var lift=0.91;
}
if(w>=835){
var lift=0.93;
}
if (imageWidth>w){
byFactor = w / imageWidth;
imageWidth = w;
imageHeight = imageHeight * byFactor;
}
if (imageHeight>h-adj){
byFactor = h / imageHeight;
imageWidth = (imageWidth * byFactor);
imageHeight = h;
}
var scrWidth = w-adj;
var scrHeight = (h*lift)-adj;
if (imageHeight>scrHeight){
imageHeight=imageHeight*lift;
imageWidth=imageWidth*lift;
}
var posLeft=0
var posTop=0
if (hugger=="hug image") {
posTop = (scrHeight-imageHeight)/2;
posLeft = ((w-imageWidth)/2);
scrHeight = imageHeight-adj;
scrWidth = imageWidth-adj;
}
imageHeight=imageHeight-adj;
imageWidth=imageWidth-adj;
newWindow = window.open("","newWindow","width="+scrWidth+",height="+scrHeight+",left="+posLeft+",top="+posTop);
newWindow.document.open();
newWindow.document.write('<html><title>'+alt+'</title><body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor='+bgcolor+' onBlur="self.close()" onClick="self.close()">');
newWindow.document.write('<table width='+imageWidth+' border="0" cellspacing="0" cellpadding="0" align="center" height='+scrHeight+' ><tr><td>');
newWindow.document.write('<img src='+imageName+' width='+imageWidth+' height='+imageHeight+' alt=\"Click\ \;screen\ \;to\ \;close.\" >');
newWindow.document.write('</td></tr></table></body></html>');
newWindow.document.close();
newWindow.focus();
}
//-->
</script>
</head>
<body>
<a href="javascript:;" onclick="JustSoPicWindow('http://www.forest53.com/gallery/images/002.jpg','400','304','demo','#FFFFFF','hug image')">Open</a>
</body>
</html>
[/html] |
通過改變window.open()裡的參數:width和height
還有一種方法就是自動獲取內容的大小而改變窗口的大小 |
那可不可以使點擊出的窗口自動居中呢 |
|