Question

net application, in which i am using some popup windows to open some pages. For this, i am using a method like this

private void OpenWindow(string Url, string height, string Width)
{
    try
    {
        string strScript = "";
        strScript += "<script language=\"javascript\">";
        strScript += "eval(\"popUpWindow('" + Url + "',0,0," + Width + "," + height + ",directories=no)\");";
        strScript += "</script>";
        lblScript.Text = strScript;
    }
    catch (Exception ex)
    {
        LogError.Log(ex);
        throw;
    }
}

JavaScript function as this:

var popUpWin = 0;

function popUpWindow(URLStr, left, top, width, height, windowName) {
    left = (screen.width / 2) - width / 2;
    top = (screen.height / 2) - height / 2;
    if (popUpWin) {
        if (!popUpWin.closed)
            popUpWin.close();
    }
    popUpWin = open(URLStr, windowName, 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width=' + width + ',height=' + height + ',left=' + left + ', top=' + top + ',screenX=' + left + ',screenY=' + top + '');
    popUpWin.focus();
}

Now its working as fine with showing the address bar. But my requirement is that i have to hide the address bar in all of my popup window. Is this possible? Please help by providing one solution. thanks in davance..

Was it helpful?

Solution

Anyway use System.Text.StringBuilder instead of string concatenation.

var sb = new StringBuilder();
sb.Append("<script language=\"javascript\">");
sb.AppendFormat("eval(\"popUpWindow('{0}',0,0,{1},{2},directories=no)\");", url, width, height);
sb.Append("</script>");
lblScript.Text = sb.ToString();

OTHER TIPS

No, it's not possible. IIRC the security feature was introduced in IE 6.

Here are some earlier discussions:

How can I hide the address bar in a modal dialog?
Can't hide status bar when doing windows.open on IE8
Popup window, how to Hide URL bar in IE8

This depends on the browser you are trying to accomplish this with.

Older browsers will allow this, but now a days, more times than not, the browser will keep showing the address bar. One of the reasons for this is to make it more difficult to make the user think you're showing a real application (virus scanner?!?) instead of a website.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow