开发者

Show lightbox to everyone besides search engines?

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 H开发者_开发技巧TML 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?


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!


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: /
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜