tatters Posted March 8, 2011 Share Posted March 8, 2011 Hi, 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 thumb it allows the option for "Open Link" but not "Open Link in New Window" or (most importantly for what I want to achieve) "Open Link in New Tab". I've done quite a bit of googling, but since I'm not proficient in php (sort of learn-as-I-go) the few things I've found don't seem to work. I've narrowed the part of the code down to the below, and hoping someone can have a look and let me know what to change it to to allow the right-click option to "Open Link in New Tab". I'm pretty sure this is the part of the code responsible: if (USE_JAVA and IMAGE_IN_NEW_WINDOW) { echo "<a href=\"javascript:void(null)\" onClick=\"javascript:window.open('" . sfpg_url(GALLERY, $images[$item], "", "imageform") . "', '', 'toolbar=no, menubar=no, location=no, scrollbars=yes, resizable=yes');\">"; } else { echo "<a" . (IMAGE_IN_NEW_WINDOW ? " target=\"_blank\"" : "") . " href=\"" . sfpg_url(GALLERY, $images[$item], PAGE, "imageform") . "\">"; } Now, I know a lot of posts out there ask how to ake something open by default in a new tab to which the answer is you can't - you can only do new window and user will decide on tab/window, this is not my issue... so just to explain further, the Single File Photo Gallery script already exclusively opens an image in my gallery in a new popup window (see javascript:window.open in the code I posted above). This is ok but not ideal for how I want to use my gallery pages. Ideally I want the OPTION to open link in new tab. It's ok for the photos to open in a new window as they do currently as long as you CAN open in a new tab if you so choose. Hmm... I still don't think I'm being clear.. You know on a link, if you right click the standard options are (from top to bottom) "Open" "Open in New Tab" "Open in New Window" etc... Well, currently the options for new tab and new window are greyed out. Here's a pic showing exactly what I mean: All help will be greatly appreciated!!! Quote Link to comment https://forums.phpfreaks.com/topic/229931-allow-option-for-%E2%80%9Copen-link-in-new-tab%E2%80%9D-in-javascriptwindowopen/ Share on other sites More sharing options...
tatters Posted March 8, 2011 Author Share Posted March 8, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/229931-allow-option-for-%E2%80%9Copen-link-in-new-tab%E2%80%9D-in-javascriptwindowopen/#findComment-1184377 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.