http://www.dynamicdrive.com/dynamicindex8/popwin.htm
popup 視窗原始碼的產生網站 , 很方便 , 先推一下

Javascript 置於 <head> ... </head> 中 , 由butoon 呼叫 NewWindow 函收,並給予參數

<script language="javascript" type="text/javascript">
    var win = null;
    function NewWindow(mypage, myname, w, h, scroll, pos) {
        if (pos == "random") { LeftPosition = (screen.width) ? Math.floor(Math.random() * (screen.width - w)) : 100; TopPosition = (screen.height) ? Math.floor(Math.random() * ((screen.height - h) - 75)) : 100; }
        if (pos == "center") { LeftPosition = (screen.width) ? (screen.width - w) / 2 : 100; TopPosition = (screen.height) ? (screen.height - h) / 2 : 100; }
        else if ((pos != "center" && pos != "random") || pos == null) { LeftPosition = 0; TopPosition = 20 }
        settings = 'width=' + w + ',height=' + h + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
        win = window.open(mypage, myname, settings);
    }
</script>

 

Asp.net C# 後台

假設我們要塞 10 個彈跳視窗的案鈕入主版頁面的可編輯區

for ( int i=0 ; i<10 ;i++)
{
     string popup_url="google.com.tw"; 
     Button uploadbtn = new Button();
     uploadbtn.ID = "UPLoad"+i;
     uploadbtn.Text = "..PopUP";
     uploadbtn.OnClientClick = "NewWindow('" + popup_url + "','mywin','480','320','no','center');return false;";
     Master.FindControl("main_page").Controls.Add(uploadbtn);
}

注 :1. button ID 不能重覆 2. 利用 onClientClick 來指定 click 事件(呼叫JAVA)

arrow
arrow
    文章標籤
    java asp.net C# popup
    全站熱搜

    jason0324 發表在 痞客邦 留言(0) 人氣()