javascript window.open in safari

The safari has a pop-up blocker silencer not show when a link is blocked.

To check if the pop-up blocker is active, go on safari settings > security > something like blocking pop-ups.

To cross it in a simple way, since I can not open a new window, I display an alert showing pop-up blocked.

In my case, I use select inputs to open external links:

HTML

<select id="retailer" class="windowOpen retailer-submenu">
    <option value="null">Select one</option>
    <option value="http://amazon.com">Amazon</option>
    <option value="http://ebay.com">eBay</option>
</select>

Javascript

<script type="text/javascript">
    $('select.windowOpen').change(function(){
        var url = $(this).val();

        var open = window.open(url);
        if (open == null || typeof(open)=='undefined')
            alert("Turn off your pop-up blocker!\n\nWe try to open the following url:\n"+url);
    });
</script>

The code to check if a pop-up is blocked is just this:

var open = window.open('http://google.com');
if (open == null || typeof(open)=='undefined')
    alert("Turn off your pop-up blocker!");

PS: the jquery trigger did not work with me.

Leave a Comment