Click here to Skip to main content
12,895,135 members (49,459 online)
Click here to Skip to main content
Add your own
alternative version


22 bookmarked
Posted 22 May 2008

Starting your website in a popup window

, 2 Jul 2008 CPOL
Rate this:
Please Sign up or sign in to vote.
You can start your website in a popup window (without having user to click even a single button)

Introduction has provided very rich environment for web development; and its keep on improving the development experience.

Most of the times we come across a problem to compare the look & feel of windows application with web application (because our clients ask us to do that :( ) and I am sure that it might have happened with most of us (especially developers working on re-engineering projects)


We were in need to find a solution to open very first page of our site as a popup window, and the only solution I got is to take help from my girlfriend...... i.e. Javascript :)

Using the code

Using the following steps, you can easily achieve this feature.

  1. Add a default.htm page in root of your web project.
  2. Write the javascript code on top of that page (ref. attached project also).
  3. Give name & path (if required) of the page you want to open in popup (most of times its default.aspx)
  4. Make default.htm as start page for that site.

Hooray.... you have successfully configured popup functionality for you website.

<script type="text/javascript" language="'javascript'">
    window.onload = poponload; 
    function poponload()
            //Set variables, version is IE version number
            var ua = window.navigator.appVersion;
            var msie = ua.indexOf ( "MSIE " );
            var version = ua.substring(msie+5,msie+6);
            //Open new window
            var now = new Date();
            var hour        = now.getHours();
            var minute      = now.getMinutes();
            var second      = now.getSeconds();
            var monthnumber = now.getMonth();
            var monthday    = now.getDate();
            var year        = now.getYear();
            var winName='master'+year+monthnumber+hour+minute+second;/*making window name dynamic*/
            /*fo in query parameter is used to tell that this site is first opening, returnURL will be used in case of forms authentication*/
            var win = ('default.aspx?fo=1', winName, "fullscreen=no,scrollbars=1,resizable=1,status=1,dependent=yes,alwaysRaised=yes");
                alert("Popups are blocked.\nMust allow popups to run the application");
                //Check version number and run correct code
                if (version >= "7")
                    if (win) 
              '', '_parent','');
                    self.opener = this;

Checking Popups are blocked

var win = ('default.aspx?fo=1', winName, "fullscreen=no,scrollbars=1,resizable=1,status=1,dependent=yes,alwaysRaised=yes");
                alert("Popups are blocked.\nMust allow popups to run the application");

You can also use the above code snippet in your application only to check that whether any respective popup is opening in browser or it is blocked by the browser / google toolbar.

Browsers Compatible

  • IE6 +


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Surjit Singh Dadhwal
Software Developer (Senior)
India India
Programming is my passion and C# is my friend, Javascript is my first crush..
Surprized!!!, don't be....
I love doing programming and writing efficient code, with the help of code project; I am able to share my experiences too with you all.

Thanks for visiting and voting this post.. [Smile | :) ]

You may also be interested in...

Comments and Discussions

GeneralThis is Great! Pin
Heywood3-Jul-08 3:49
memberHeywood3-Jul-08 3:49 
GeneralRe: This is Great! Pin
Surjit Singh Dadhwal29-Jul-08 10:59
memberSurjit Singh Dadhwal29-Jul-08 10:59 
Generalgreate Pin
Abhijit Jana3-Jul-08 0:41
memberAbhijit Jana3-Jul-08 0:41 
GeneralYour article really helped us!!! Keep it up. Pin
Vinit Singh26-May-08 23:09
memberVinit Singh26-May-08 23:09 
General[Message Removed] Pin
Mojtaba Vali23-May-08 21:59
memberMojtaba Vali23-May-08 21:59 
GeneralRe: starting step Pin
Surjit Singh Dadhwal25-May-08 19:37
memberSurjit Singh Dadhwal25-May-08 19:37 
GeneralNo visible use Pin
Xiotox23-May-08 13:05
memberXiotox23-May-08 13:05 
GeneralRe: No visible use Pin
Surjit Singh Dadhwal25-May-08 19:41
memberSurjit Singh Dadhwal25-May-08 19:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170424.1 | Last Updated 3 Jul 2008
Article Copyright 2008 by Surjit Singh Dadhwal
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid