http://www.dynamicdrive.com/dynamicindex8/popwin.htm
popup 視窗原始碼的產生網站 , 很方便 , 先推一下
Javascript 置於 <head> ... </head> 中 , 由butoon 呼叫 NewWindow 函收,並給予參數
|
<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>"> |
|
<span style="color: #0000ff">var</span> win = <span style="color: #0000ff">null</span>; |
|
<span style="color: #0000ff">function</span> NewWindow(mypage, myname, w, h, <span style="color: #0000ff">scroll</span>, pos) { |
|
<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; } |
|
<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; } |
|
<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 } |
|
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'; |
|
win = <span style="color: #0000ff">window</span>.<span style="color: #0000ff">open</span>(mypage, myname, settings); |
Asp.net C# 後台
假設我們要塞 10 個彈跳視窗的案鈕入主版頁面的可編輯區
|
<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++) |
|
<span style="color: #0000ff">string</span> popup_url="<span style="color: #8b0000">google.com.tw</span>"; |
|
Button uploadbtn = <span style="color: #0000ff">new</span> Button(); |
|
uploadbtn.ID = "<span style="color: #8b0000">UPLoad</span>"+i; |
|
uploadbtn.Text = "<span style="color: #8b0000">..PopUP</span>"; |
|
uploadbtn.OnClientClick = "<span style="color: #8b0000">NewWindow('</span>" + popup_url + "<span style="color: #8b0000">','mywin','480','320','no','center');return false;</span>"; |
|
Master.FindControl("<span style="color: #8b0000">main_page</span>").Controls.Add(uploadbtn); |
注 :1. button ID 不能重覆 2. 利用 onClientClick 來指定 click 事件(呼叫JAVA)