http://www.dynamicdrive.com/dynamicindex8/popwin.htm
popup 視窗原始碼的產生網站 , 很方便 , 先推一下
Javascript 置於 <head> ... </head> 中 , 由butoon 呼叫 NewWindow 函收,並給予參數
1 |
<pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><script language="<span style="color: #8b0000">javascript</span>" type="<span style="color: #8b0000">text/javascript</span>"> |
1 |
<span style="color: #0000ff">var</span> win = <span style="color: #0000ff">null</span>; |
1 |
<span style="color: #0000ff">function</span> NewWindow(mypage, myname, w, h, <span style="color: #0000ff">scroll</span>, pos) { |
1 |
<span style="color: #0000ff">if</span> (pos == "<span style="color: #8b0000">random</span>") { LeftPosition = (screen.width) ? <span style="color: #0000ff">Math</span>.floor(<span style="color: #0000ff">Math</span>.random() * (screen.width - w)) : 100; TopPosition = (screen.height) ? <span style="color: #0000ff">Math</span>.floor(<span style="color: #0000ff">Math</span>.random() * ((screen.height - h) - 75)) : 100; } |
1 |
<span style="color: #0000ff">if</span> (pos == "<span style="color: #8b0000">center</span>") { LeftPosition = (screen.width) ? (screen.width - w) / 2 : 100; TopPosition = (screen.height) ? (screen.height - h) / 2 : 100; } |
1 |
<span style="color: #0000ff">else</span> <span style="color: #0000ff">if</span> ((pos != "<span style="color: #8b0000">center</span>" && pos != "<span style="color: #8b0000">random</span>") || pos == <span style="color: #0000ff">null</span>) { LeftPosition = 0; TopPosition = 20 } |
1 |
settings = 'width=' + w + ',height=' + h + ',<span style="color: #0000ff">top</span>=' + TopPosition + ',left=' + LeftPosition + ',<span style="color: #0000ff">scrollbars</span>=' + <span style="color: #0000ff">scroll</span> + ',<span style="color: #0000ff">location</span>=no,directories=no,<span style="color: #0000ff">status</span>=no,<span style="color: #0000ff">menubar</span>=no,<span style="color: #0000ff">toolbar</span>=no,resizable=no'; |
1 |
win = <span style="color: #0000ff">window</span>.<span style="color: #0000ff">open</span>(mypage, myname, settings); |
1 |
} |
1 |
</script> |
Asp.net C# 後台
假設我們要塞 10 個彈跳視窗的案鈕入主版頁面的可編輯區
1 |
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><span style="color: #0000ff">for</span> ( <span style="color: #0000ff">int</span> i=0 ; i<10 ;i++) |
1 |
{ |
1 |
<span style="color: #0000ff">string</span> popup_url="<span style="color: #8b0000">google.com.tw</span>"; |
1 |
Button uploadbtn = <span style="color: #0000ff">new</span> Button(); |
1 |
uploadbtn.ID = "<span style="color: #8b0000">UPLoad</span>"+i; |
1 |
uploadbtn.Text = "<span style="color: #8b0000">..PopUP</span>"; |
1 |
uploadbtn.OnClientClick = "<span style="color: #8b0000">NewWindow('</span>" + popup_url + "<span style="color: #8b0000">','mywin','480','320','no','center');return false;</span>"; |
1 |
Master.FindControl("<span style="color: #8b0000">main_page</span>").Controls.Add(uploadbtn); |
1 |
} |
1 |
注 :1. button ID 不能重覆 2. 利用 onClientClick 來指定 click 事件(呼叫JAVA)
(Visited 33 times, 1 visits today)