Code Snippets: Opening a new window from JavaScript across all browsers

Much to every developers pain we often find that JavaScript that is functional in one browser is not functional in other browsers.  Recently the update to Safari 3 requrired that the window open command to not contain the url. As it would fail to open a window if it did, the simple fix was to create a new window with no url and set the url after creating the window. However as other brothers do not require this we can set up a two step process in that we try to open the window normally and if it fails then we open one with no url defined.

function create_popup( url, win_title, win_options )
  var popWin = url, win_title, win_options );
  if( !popWin ) {
    popWin ='', win_title, win_options);
    popWin.location.href = url;

Comments & Questions

Add Your Comment