DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

How To Open Links In Current Window, New Window, Background.

  • submit to reddit
function open2(url, opt){
  if (opt == 0) // current window
    window.location = url;
  else if (opt == 1) // new window;
  else if (opt == 2) // background window
    {; self.focus();}


Carla Brian replied on Thu, 2012/07/26 - 6:32pm

Good tips by the way. I want to learn how to do this one. Good thing  I saw your post. - Mercy Ministries

Snippets Manager replied on Wed, 2010/06/09 - 7:33am

I've been looking all over for this *seemingly* simple thing. Thanks alot for solving my life problems in a few lines of code. *POST MOAR*