Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hello All,
I am using the following code to open a new page in java script but web browsers are giving the warning of pop-up blocker

XML
<script language="javascript" type="text/javascript">
        function showPDF() {
            var popUp = window.open("PDFContainer.aspx", '_blank');
            return (popup)?false:true;
        }
    </script>


How to open a page in new window if pop up blocker warning is there(not to allow manually popup blocker)
Posted
Updated 16-Dec-18 17:34pm
v2

This is a question of the type: "Doing X is not allowed. How to do X?" :-)

If a popup blocker allowed you to do a popup, it would be a very bad blocker, and people would not use it.

Please understand that a popup blocker is always a step ahead of you: it uses interface to a concrete Web browser which in turn take a total control of all rendering and scripting on the client side. And your application is supposed to work with all kinds of HTTP client software and be somewhat abstracted from it. From this point, it's easy to understand that it's much easier for a blocker to block your code then break this blocking.

—SA
 
Share this answer
 
Comments
Abhinav S 10-Oct-12 23:37pm    
5!
Sergey Alexandrovich Kryukov 11-Oct-12 0:17am    
Thank you, Abhinav.
--SA
I second what Sergey said. That's the whole point of having a popup blocker! Why not just open something like a jquery ui dialog ?

http://jqueryui.com/dialog/[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 11-Oct-12 0:25am    
Good idea, a 5. It could be even the modal window (OP can find many samples).
--SA
Karthik. A 11-Oct-12 9:03am    
Thank you Sergey!
The answer is as simple as "no you cant".

Imagine you turn on a popup blocker on your browser and some malicious users is still able to open a popup when you are browsing a site - beats the whole idea of a popup blocker, doesn't it.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 11-Oct-12 0:26am    
Right, a 5.
--SA
Abhinav S 11-Oct-12 12:37pm    
Thank you SA.
Hello All,
I am using the following code to open a new page in java script but web browsers was pop-up blocked

var script = "window.open('', '_blank')";
WebWindow.CurrentRequestWindow.RegisterStartupScript("clientScriptForNonModalWindow", script);
 
Share this answer
 
Comments
Richard Deeming 18-Dec-18 12:14pm    
So rather than read the existing solutions, which would explain why there is no way of doing what you are trying to do, you decided to post your question as a SOLUTION to someone else's question?

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900