Click here to Skip to main content
15,885,244 members
Articles / Web Development / XHTML

Extending the Hyperlink control to use JavaScript to create a popup

Rate me:
Please Sign up or sign in to vote.
3.83/5 (6 votes)
2 Nov 2008CPOL1 min read 32.3K   138   21  
Make your Hyperlink control use JavaScript to create a popup window.
function Showpopup(PagePath,target, height, width, menubar, locationbar, resizable, scrollbars, status, titlebar, toolbar, fullscreen) {
    var currentIndex = 0;

   
    var ProbsArray = new Array();

    if (height != "") { ProbsArray[currentIndex] = "height=" + height; currentIndex++; }
    if (width != "") { ProbsArray[currentIndex] = "width=" + width; currentIndex++; }
    if (menubar != "") { ProbsArray[currentIndex] = "menubar=" + menubar; currentIndex++; }
    if (locationbar != "") { ProbsArray[currentIndex] = "location=" + locationbar; currentIndex++; }
    if (resizable != "") { ProbsArray[currentIndex] = "resizable=" + resizable; currentIndex++; }
    if (scrollbars != "") { ProbsArray[currentIndex] = "scrollbars=" + scrollbars; currentIndex++; }
    if (status != "") { ProbsArray[currentIndex] = "status=" + status; currentIndex++; }
    if (titlebar != "") { ProbsArray[currentIndex] = "titlebar=" + titlebar; currentIndex++; }
    if (toolbar != "") { ProbsArray[currentIndex] = "toolbar=" + toolbar; currentIndex++; }
    if (fullscreen != "") { ProbsArray[currentIndex] = "fullscreen=" + fullscreen; currentIndex++; }
    
    
    var top = parseInt((screen.availHeight / 2) - (height / 2));
    if (width != "") 
    {
        var left = parseInt((screen.availWidth / 2) - (width / 2));
        ProbsArray[currentIndex] = "left=" + left;
        currentIndex++;
        ProbsArray[currentIndex] = "screenX=" + left;
        currentIndex++; 
    }
    if (height != "") 
    {
        ProbsArray[currentIndex] = "top=" + top; currentIndex++;
        ProbsArray[currentIndex] = "screenY=" + top; currentIndex++;
    }

    window.open(PagePath, target, ProbsArray.join(","));
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Software Developer (Senior) LexisNexis
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions