Function to Open URL's in a new browser window


/ Published in: JavaScript
Save to your folder(s)

Call this function with a URL and it will open it in a new browser window. Its synonymous to auto clicking a link with the target="_blank" attribute set.


Copy this code and paste it in your HTML
  1. function myOpenWindowCode()
  2. {
  3. var oWin = window.open("http://www.google.com", '_blank');
  4. if (oWin) {
  5. if (oWin.focus) oWin.focus();
  6. return false;
  7. }
  8. oWin = null;
  9. return true;
  10. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.