允许选项“在新标签页中打开链接”在javascript:window.open [英] Allow option for "Open Link in New Tab" in javascript:window.open

查看:120
本文介绍了允许选项“在新标签页中打开链接”在javascript:window.open的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用单个文件照片库,并希望为脚本制作一个mod ...当前左键单击时,图像会在新的弹出窗口中打开。如果你右键单击图像拇指,它允许选择打开链接但不允许在新窗口中打开链接或(最重要的是我想要实现的目标)在新标签中打开链接。
我已经完成了相当多的谷歌搜索,但由于我不精通PHP(有点学习我去),我发现的一些东西似乎不起作用。
我已将代码的一部分缩小到下面,并希望有人可以查看并让我知道要将其更改为允许右键单击选项在新标签中打开链接
非常感谢。

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" Many thanks.

          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") . "\">";
      }

好的,不知道为什么会被主持人Tim Post删除,它本来是对我的问题的进一步解释......无论如何,我会重新发布,因为我认为我没有违反任何准则,图片的链接也只是对我的问题的进一步解释。

Okay, not sure why this was deleted by Tim Post who is a moderator, it was meant to be a further explanation of my problem... Anyway, I will repost as I don't think I've broken any guidelines, the link to the pic is just a further explanation of my issue too.

(天哪,你能说我在这里是个新手吗?我不能把评论搞砸了,丢失到目前为止我至少输了5次...无论如何这就是我想给亚历克斯写的......)

(Oh god can you tell I'm a newbie here? I can't work the comment thingy out, lost what I typed at least 5 times so far... Anyway this is what I was trying to write to Alex... )

你好Alex,谢谢你的时间,我想我没有正确解释我的问题...单个文件照片库脚本已经在一个新的弹出窗口中专门在我的库中打开一个图像(请参阅上面发布的代码中的javascript:window.open)。

Hi Alex, thank you for your time, I guess I didn't explain my issue properly... The Single File Photo Gallery script does already exclusively open 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.

理想情况下,我希望OPTION在新标签页中打开链接。如果您愿意,只要您可以在新标签中打开照片,就可以在新窗口中打开照片。

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.

我会尝试发布我的意思(如果可行)的图片

I'll try to post a pic of what I mean (if it works)

确定.. 。pic不起作用......所以这里是链接:

Ok... pic doesn't work... so here's the link:

http://i.stack.imgur.com/1UFaM.jpg

推荐答案

我已经设法解决了这个问题...

I've managed to work it out...

我删除了这行代码:

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

剩下这个:

  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.

这篇关于允许选项“在新标签页中打开链接”在javascript:window.open的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆