function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
}
else {
window.onload = function() {
oldonload();
func();
}
}
}
function insertAfter(newElement, targetElement) {
var parent = targetElement.parentNode;
if (parent.lastChild == targetElement) {
parent.appendChild(newElement);
}
else {
parent.insertBefore(newElement,targetElement.nextSibling);
}
}
function addClass(element,value){
if(!element.className){
element.className=value;
}else{
newClassName=element.className;
newClassName+=" ";
newClassName+=value;
element.className=newClassName;
}
}
function styleElementSiblings(tag,theclass){
if (!document.getElementsByName) return false;
var elems = document.getElementsByTagName(tag);
for (var i = 0; i, elems.length; i++) {
var elem = getNextElement(elems[i].nextSibling);
addClass(elem, theclass);
}
}
-------------
function moveElement(elementID,final_x,final_y,interval){
if(!document.getElementById) return false;
if(!document.getElementById("message")) return false;
var elem=document.getElementById(elementID);
var xpos=parseInt(elem.style.left);
var ypos=parseInt(elem.style.top);
if(xpos==final_x && ypos== final_y){
return true;
}
if(xpos<final_x){
xpos++;
}
if(xpos>final_x){
xpos--;
}
if(ypos<final_y)
{
ypos++;
}
if(ypos>final_y)
{
ypos--;
}
elem.style.left=xpos+"px";
elem.style.top=ypos+"px";
var repeat="moveElement('"+elementID+"',"+final_x+","+final_y+","+interval+")";
movement=setTimeout(repeat,interval);
}
为链接设置快速访问键
如何设置快速访问键并没有一定的规定,但一些比较基本的快速访问键都有约定俗成的设置办法,对此感兴趣的读者可以浏览 http://www.clagnut.com/blog/193,一般来说,accesskey=1对应着一个“返回本站主页”的链接;accesskey=“2”对应着一个“后退到前一页面”的链接;accesskey=“4”对应着一个“打开本站的搜索页面/表单”的链接;accesskey=“9”对着一个“本站联系办法”的链接;accesskey=“0”对应着一个“查看本站的快速访问键”的链接
Access key | Target |
---|---|
S | Skip navigation |
1 | Home page |
2 | What’s new |
3 | Site map |
4 | Search |
5 | FAQs |
6 | Help |
7 | Complaints procedure |
8 | Terms and conditions |
9 | Feedback form |
0 | Access key details |
WebAIM provides similar shortcuts:
Access key | Target |
---|---|
1 | Home page |
2 | Skip navigation |
3 | Printer-friendly version |
4 | Search |
These almost match with the access keys used by Mark Pilgrim (accessibility evangelist):
Access key | Target |
---|---|
1 | Home page |
2 | Skip navigation |
4 | Search |
0 | Access key details |
And finally, the accessibility magazine Made For All (now sadly no more) uses a few different shortcuts:
Access key | Target |
---|---|
1 | Home page |
2 | News |
3 | Previous issues |
4 | Resources |
5 | About |
0 | Access key details |
So there’s a fair bit of overlap between sites. The use of numbers is sensible as software often uses letters for its own shortcuts, particularly for access to the command menu. Letters also make more sense when dealing with forms (think shortcuts in dialog boxes). So the main bone of contention appears to be skip nav. Here’s a few samples:
Shortcut | Web Site |
---|---|
2 | Dive Into Mark |
2 | Zeldman |
2 | WebAIM |
9 | Cinnamon Interactive |
C | Clagnut |
C | Accessify |
S | UK Government |