Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
572 views
in Technique[技术] by (71.8m points)

javascript - window.open with popup blocker

I am trying to open a certain page from my default page. All the code there is in the default page is:

<script type="text/javascript">
        window.open("StartPage.aspx", "", "fullscreen=yes");  
</script>

The problem is that the browser's popup blocker blocks this and I need allow the browser to open it. I want to avoid this and that every one that will use my web application won't need to allow the popup blocker to open the page. I want to pass the popup blocker and open the page without permission.

Is there a way to do so? Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

adamantium is right. a popup blocker would be pretty useless if it could be overridden by the code that's causing the popup. the best you can do is this:

<script type="text/javascript">
    var myPopup = window.open("StartPage.aspx", "", "fullscreen=yes");  
    if(!myPopup)
        alert('a popup was blocked. please make an exception for this site in your popup blocker and try again');
</script>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...