向搜索引擎以外的所有人展示灯箱?

发布于 2024-10-26 21:50:55 字数 155 浏览 7 评论 0原文

有没有什么可以让我在页面加载时向所有用户显示灯箱,但不向 Google 显示?请注意,我的技能是非常基本的 HTML,因此任何包含详细信息的回复将不胜感激。

编辑:我刚刚意识到搜索引擎无论如何都不会加载 JavaScript,对吗?这就是我的第二个问题:如何在页面加载时加载灯箱?

Is there any that that I can show a lightbox to all users on page load but dont show it to Google? Note that my skills are very basic HTML so any reply would be appreciated with details.

Edit: I just realised that search engines wont load javascript anyway, right? That comes to my second question: How do I make a lightbox load on pageload?

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

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

发布评论

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

评论(2

一抹苦笑 2024-11-02 21:50:55

确实很难让机器人远离任何事情。但是,如果它们是所谓的“行为良好的机器人”(例如 Google),您可以编写 robots.txt 文件来告诉它们不要查看某些页面。看看 http://www.robotstxt.org/

所以,如果你愿意..你可以添加您保存图像的目录,以防止机器人入侵。请记住,它只会阻止遵守这些规则的机器人,这就是互联网的本质!

It's hard to keep bots off of anything really. However, if they're what's known as "well behaved robots" (such as Google) you can write a robots.txt file to tell them not to look at certain pages. Have a look at http://www.robotstxt.org/

So, if you wanted.. you could add the directory which you keep your images in to keep the robots away. Just remember it'll only keep the robots which obey these rules away such is the nature of the Internet!

三人与歌 2024-11-02 21:50:55

要在页面加载时加载灯箱,您可以执行以下操作:

对于版本 2.04+,在第 173 行周围找到此代码(在 lightbox.js 中)并替换与以下代码类似的部分:

var th = this;
(function(){
var ids = 
'overlay lightbox outerImageContainer imageContainer lightboxImage hoverNav prevLink nextLink loading loadingLink ' + 
'imageDataContainer imageData imageDetails caption numberDisplay bottomNav bottomNavClose'; 
$w(ids).each(function(id){ th[id] = $(id); });
if (document.getElementById('first')) {
th.start(document.getElementById('first'));
}
}).defer();

},

然后基本上附加您想要的灯箱图像首先在 标记上使用 id='first'

<a id="first" href="images/image-1.jpg" rel="lightbox"><img src="images/thumb-1.jpg" width="100" height="40" alt="" /></a>

回到您的第一个问题。我假设您正在尝试阻止搜索引擎机器人抓取您的图像并将其索引到搜索中。根据 @Aidanc 的建议,谷歌机器人对此非常“友善”,您基本上可以修改 robots.txt 文件,告诉机器人不要抓取某个文件夹。在您的示例中将是您的灯箱图像文件夹。例如,以下内容将禁止机器人爬行 /lightbox/images/ forlder:

User-agent: *
Disallow: /lightbox/images/
Allow: /

To make a lightbox load on pageload you can do the following:

For version 2.04+, find this code (in lightbox.js) around line 173 and replace the part that's similar to the following code:

var th = this;
(function(){
var ids = 
'overlay lightbox outerImageContainer imageContainer lightboxImage hoverNav prevLink nextLink loading loadingLink ' + 
'imageDataContainer imageData imageDetails caption numberDisplay bottomNav bottomNavClose'; 
$w(ids).each(function(id){ th[id] = $(id); });
if (document.getElementById('first')) {
th.start(document.getElementById('first'));
}
}).defer();

},

Then basically attach the lightbox image that you want to start first with an id='first' on the <a> tag:

<a id="first" href="images/image-1.jpg" rel="lightbox"><img src="images/thumb-1.jpg" width="100" height="40" alt="" /></a>

Referring back to your first question. I am assuming you are trying to keep search engine robots from crawling your images and index into the search. As per @Aidanc suggests, google bots are pretty "nice" about it and you can basically modify your robots.txt file in a way to tell the bots not to crawl a certain folder. In your example would be your lightbox images folder. For example, the following would disallow bots crawling through /lightbox/images/ forlder:

User-agent: *
Disallow: /lightbox/images/
Allow: /
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文