Skip to content Skip to sidebar Skip to footer

Allow Option For "open Link In New Tab" In Javascript:window.open

I'm using Single File Photo Gallery and want to make one mod to the script... Currently the images open in a new pop up window when left-clicked. If you right click on the image th

Solution 1:

You can not force the browser to open in exclusively a tab or window, best you can do is with _blank which will be a new window or tab depending on the browser and its settings.

Best thing you could do is do a oncontextmenu event, make your own menu, and your own button which calls window.open(url, '_blank'), however, replacing user's context menus is very annoying and often disabled.

Solution 2:

I've managed to work it out...

I deleted this line of code:

  {
    echo "<a href=\"javascript:window.open('" . sfpg_url(GALLERY, $images[$item], "", "imageform") . "', '', 'toolbar=no, menubar=no, location=no, scrollbars=yes, resizable=yes');\">";
  }
  else

To be left with just this:

if (USE_JAVA and IMAGE_IN_NEW_WINDOW)
  {
    echo "<a" . (IMAGE_IN_NEW_WINDOW?" target=\"_blank\"" : "") . " href=\"" . sfpg_url(GALLERY, $images[$item], PAGE, "imageform") . "\">";
  }

And it still automatically opens the image in the new window, the only thing is that it keeps the toolbar/menubar/location/etc in the new window, but it does also allow the option to left click and open in new tab! So it might not be as pretty and neat when left clicked, but at least it's got full functionality on the right click! That's good enough for what I want in any case.

Post a Comment for "Allow Option For "open Link In New Tab" In Javascript:window.open"