使用javascript Window.open()打开一个弹出窗口 [英] open a popup window using javascript Window.open()

查看:289
本文介绍了使用javascript Window.open()打开一个弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,



我有一个gridview。对于gridview中的每一行,我都有一个linkbutton。当我们点击该链接时,它需要打开一个弹出窗口(已经存在的页面需要显示为弹出窗口)。

我已经在下面的代码中写了这个。



它在IE9中工作正常,但在IE8中出错。



- >当我点击gridview中的链接时,它应该关闭已经存在的弹出窗口&需要用新的id再次打开弹出窗口。



请尽快帮助我..







Hi Friends,

I have a gridview. For each row in gridview, i have a linkbutton. When we click on that link then it needs to open a popup window (already exsting page need to show as popup).
I have written this in code behind like below.

It is working fine in IE9 but getting error in IE8.

--> when i click on the link in gridview, it should close the already exsting popup & needs to open popup again with the new id.

Please help me asap..



protected void dgPO_EditCommand(object source, DataGridCommandEventArgs e)
    {
        try
        {
            string strInvoiceID = e.Item.Cells[0].Text.ToString();
            string url;
            url = "./Invoice.aspx?InvoiceID=" + strInvoiceID.ToString();
            Session["url"] = url;
            string winFeatures = "toolbar=no,status=no,menubar=no,location=center,scrollbars=yes,resizable=no,height=650,width=825";
            ClientScript.RegisterStartupScript(this.GetType(), "newWindow", string.Format("<script type='text/javascript'>var popup=window.open('{0}', 'yourWin', '{1}'); popup.focus();</script>", url, winFeatures));

        }
        catch (Exception ex)
        {
            lblstatus.Text = ex.Message.ToString();
        }
    }

推荐答案

hi,



请检查以下网址



GridView的弹出窗口 [ ^ ]



谢谢。


please check below url

Popup window for the GridView[^]

Thanks.


您好,

试一试:

Hi,
Try this:
// open a pop up window at the center of the page.
ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", "var Mleft = (screen.width/2)-(760/2);var Mtop = (screen.height/2)-(700/2);window.open( '39;your_page.aspx?InvoiceID='" + strInvoiceID.ToString();+"', null, 'height=700,width=760,status=yes,toolbar=no,scrollbars=yes,menubar=no,location=no,top=\'+Mtop+\', left=\'+Mleft+\'' );", true);





--Amit



--Amit


string url = Invoice.aspx?InvoiceID=" + strInvoiceID.ToString() + "&";
 string str = Guid.NewGuid().ToString();
 str = str.Replace('-', '0');
 str = 'w' + str;
 System.Text.StringBuilder sb = new System.Text.StringBuilder();
 sb.Append(@"&lt;script language='javascript'>");
 sb.Append(@"PopWin('" + url + "','" + str + "', 'CallingFormName.aspx', '', '1024', '620');");
 sb.Append(@"</script>");
 System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "JCall1", sb.ToString(), false);

// Write following function in script block of .aspx page

function PopWin(varURL, varWindowName, varCaller, varKeyId, varWidth, varHeight) {
    var objTransparent = document.getElementById("Transparent");
    var height = document.body.clientHeight + 'px';
    document.documentElement.scrollTop = 0;
    if (navigator.appName == "Microsoft Internet Explorer")
        objTransparent.style.height = "100%";
    else
        objTransparent.style.height = height;

    objTransparent.style.width = "100%";

    objTransparent.style.visibility = 'visible';

    var varLeft = (screen.width / 2) - (varWidth / 2);
    var varTop = (screen.height / 2) - (varHeight / 2);

    popupWindow = window.open(varURL + 'Caller=' + varCaller + '&Id=' + varKeyId + '&ShowModal=1', varWindowName, 'width=' + (screen.width - 10) + 'px; height=' + (screen.height - 70) + 'px; top=' + 0 + '; left=' + 0 + '; location=0 ;resizable=1; scrollbars=1');

}


这篇关于使用javascript Window.open()打开一个弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆