2008/9/27 Magnus Eklund <[EMAIL PROTECTED]>:
> 2008/9/27 Mck <[EMAIL PROTECTED]>:
>> On Sat, 2008-09-27 at 16:10 +0200, Magnus Eklund wrote:
>>> There is variant of this solution with the benefit of more readable
>>> and maintainable HTML. Use CSS classes to provide the information
>>> about your links:
>>>
>>> <a href="http://somesite.com" class="boomerang
>>> boomerang_static_home">Click Me</a>
>>
>> Nice solution magnus.
>> Since it avoids the redirect you think this would be better for
>> crawlers? Or would the javascript confuse/deter them?
>
> Thanks. Yes, I'm pretty sure that this will cause no problems for the
> crawlers.
>
>>
>> The BoomerangServlet has to check if the client is a crawler so to use a
>> 301 redirect instead. This problem might be avoided here?
>>
>
> Yes.
>
> But, I went ahead and actually tried this code and it does not seem to
> work in all browsers. Using safari no ajax request is sent. The reason
> probably being that javascript execution is halted as the browser
> leaves the page, before the asynchronous boomerang request has been
> sent. I will investigate it further.
>
Here is another version that appears to be working better. It uses the
mousedown event instead of the click event. It has also been rewritten
to avoid iterating all the links at page load time and will work for
dynamically added links too:
Event.observe(document, 'mousedown', function(event) {
var element = Event.findElement(event, 'a');
if (element && element.hasClassName('boomerang')) {
element.classNames().each(function(name) {
if (name.startsWith('boomerang_')) {
var called = false;
var parts = name.split('_');
new Ajax.Request('/hunting/', {
method: 'get',
parameters: {category: parts[1],
subcategory: parts[2] }
});
return;
}
});
}
});
- Magnus
_______________________________________________
Kernel-development mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-development