简体   繁体   中英

Prevent asp popup window from pop up blocker

I am using the following code to get popup window in asp .net before sending text in database. But due to popup blocker pop up dose not come.

string strPopup = "<script language='javascript' ID='script1'>"

    // Passing intId to popup window.
    + "window.open('sharepopup.aspx?data=" + HttpUtility.UrlEncode(intId.ToString())

    + "','new window', 'top=90, left=200, width=500, height=500, dependant=no, location=0, alwaysRaised=no, menubar=no, resizeable=no, scrollbars=n, toolbar=no, status=no, center=yes')"

    + "</script>";

        ScriptManager.RegisterStartupScript((Page)HttpContext.Current.Handler, typeof(Page), "Script1", strPopup, false);
  cmd = new SqlCommand("Insert Into ChatTB values(column names) ", con);

You can't - because that's what popup blockers do: they block popup windows (ie calls to window.open or invocations of target="_blank" links) unless it is directly in response to a user mouse action.

Alternatively you can use Jquery

$("#dialog-message").dialog({
    modal: true,
    draggable: false,
    resizable: false,
    position: ['center', 'top'],
    show: 'blind',
    hide: 'blind',
    width: 400,
    dialogClass: 'ui-dialog-osx',
    buttons: {
        "ok": function() {
            $(this).dialog("close");
        }
    }
});

Here is the fiddle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM