Hi Friends ........
how to popup a browser window when pageload event occurs.

Recommended Answers

All 4 Replies

You may use JavaScript function.

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
    <script language="JavaScript">
    function openWindow()
    {
var w = 0, h = 0;
            if (document.all || document.layers)
            { 
               w = screen.availWidth;
               h = screen.availHeight;
            }
            var popW = 550, popH = 350;
            var leftc = (w - popW) / 2, topc = (h - popH) / 2;
            window_bbs = window.open('Transactions/BBS/BrowseNewMessage.aspx','window_bbs','scrollbars=yes,left=' + leftc + ', top=' + topc + ',width=550,height=350');
            window_bbs.focus();
    }
    </Script>
</head>
<body onload="openWindow()">

</body>
</html>

Thanks.

If you want to do this at server side code in the Page_Load event

Do the following steps:

1. Make your <body> tag server accessible by setting runat='server' and an id.

<body  id="bodyDemoPage" runat="server">

2. And then add the following code in your Page_Load event.

protected void Page_Load(object sender, EventArgs e)
    {
                bodyDemoPage.Attributes.Add("onload", "window.open('DemoPage1.aspx')");
        }

a large proportion of visitors will have disabled popup as a security fault,
its not a good plan
a visible/invisible over layer within the page would be better

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.