Project

General

Profile

1
/**
2
 * "Yet Another Multicolumn Layout" - (X)HTML/CSS Framework
3
 *
4
 * (en) Workaround for Webkit browser to fix focus problems when using skiplinks
5
 * (de) Workaround für Webkit-Browser, um den Focus zu korrigieren, bei Verwendung von Skiplinks
6
 *
7
 * @note			inspired by Paul Ratcliffe's article 
8
 *					http://www.communis.co.uk/blog/2009-06-02-skip-links-chrome-safari-and-added-wai-aria
9
 *
10
 * @copyright       Copyright 2005-2009, Dirk Jesse
11
 * @license         CC-A 2.0 (http://creativecommons.org/licenses/by/2.0/),
12
 *                  YAML-C (http://www.yaml.de/en/license/license-conditions.html)
13
 * @link            http://www.yaml.de
14
 * @package         yaml
15
 * @version         3.2
16
 * @revision        $Revision: 430 $
17
 * @lastmodified    $Date: 2009-10-27 21:15:57 +0100 (Di, 27. Okt 2009) $
18
 */
19
 
20
var is_webkit = navigator.userAgent.toLowerCase().indexOf('webkit') > -1;
21

    
22
if(is_webkit) 
23
{
24
	var i;
25
	var skiplinks = []
26
	
27
	if ( document.getElementsByClassName !== undefined) {
28
		skiplinks = document.getElementsByClassName('skip');
29

    
30
		for (i=0; i<skiplinks.length; i++) {
31
			var target = skiplinks[i].href.substr(skiplinks[i].href.indexOf('#')+1);
32
			var targetElement = document.getElementById(target);
33
	
34
			targetElement.href = '#'+target;
35
			targetElement.setAttribute("tabindex", "0");
36
	
37
			skiplinks[i].setAttribute("onclick", "document.getElementById('"+target+"').focus();");
38
		}
39
	}	
40
}
(5-5/5)