检测图像是在 iframe 中显示还是单独显示

发布于 2024-11-28 04:25:21 字数 289 浏览 5 评论 0原文

我正在构建一个系统,允许人们通过 thickbox 查看图片。但我有一个问题。通过PHP和普通HTML直接显示thickbox中的图片。它的显示没有任何 CSS 界面,页面只是查看普通图片。如果通过厚盒查看图片,这很好。但如果用户想同时打开一张以上的图片,用户可能会在新标签页上打开图片,在这种情况下,图片将显示在页面上,而不显示任何内容。那看起来不太好。

如何检测用户是通过厚盒查看图片还是通过整个浏览器作为整页查看图片?

I am building a system that allows people to view pictures through thickbox. But I have a problem. The picture in the thickbox gets displayed directly through PHP and normal HTML. It gets displayed without any CSS interface and the page just views the plain picture. This is fine if the picture is viewed through the thickbox. But if the user wanted to open more than 1 picture at the same time, the user might open the pics on new tabs, and in this case the picture will be displayed on the the page without anything. And that won't look good.

How can I detect if the user is viewing the picture through the thickbox or through the whole browser as a full page?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

明天过后 2024-12-05 04:25:21

解决此问题的方法是修改 view_picture.php 文件以包含一个参数,该参数说明视图当前采用的格式。例如:

<a href="view_picture.php?pid=<?php echo $pid; ?>&view=thickbox" class="thickbox" rel="gallery-plants"><img src="<?php echo $cover; ?>" /></a>

请注意添加 &view =thickboxhref 属性

然后在您的 view_picture.php 中添加如下内容:

if($_GET['view'] !== 'thickbox'){
    // display the picture with other html etc
}
else {
    // display the picture without any extra content (as it is currently)
}

A solution to this would be to modify your view_picture.php file to include an argument that states what format the view is currently in. For example:

<a href="view_picture.php?pid=<?php echo $pid; ?>&view=thickbox" class="thickbox" rel="gallery-plants"><img src="<?php echo $cover; ?>" /></a>

Note the addition of &view=thickbox to the href attribute

Then in your view_picture.php something like the following:

if($_GET['view'] !== 'thickbox'){
    // display the picture with other html etc
}
else {
    // display the picture without any extra content (as it is currently)
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文