Jojoxx.net logotyp

 

 

Användare ikonAnvändare
Besökare just nu: 69
Snabblänkar ikonSnabblänkar
JavaScript-arkivet
Perl
FAQ

Sök på Jojoxx.net


Tangentbordsnavigering 2

Exempel

Kod


<script type="text/javascript">
/*  The code contained in this  file is copyrighted by www.jojoxx.net
The file may be used for none commercial applications and distributed
as long as these lines remain intact.  The file or part of it may not
be sold  or  included  in any  other commercial  application  without
agreement from the author. If you have questions or comments, contact
the author at http://www.jojoxx.net

© Copyright - www.jojoxx.net - 2004                                */

var navigation=new Object();
navigation['1']={ text:"jojoxx.net", url:"http://www.jojoxx.net" };
navigation['2']={ text:"webForum", url:"http://www.webforum.nu/", target:"_blank" };
navigation['G']={ text:"Google", url:"http://www.google.com/", target:"_blank" };
navigation['J']={ text:"jojoxx.net", url:"http://www.jojoxx.net" };

// Ändra inte raderna nedan.
with(document){
write('<div id="jojoxxkeynavigation" style="position:absolute;width:200px;visibility:hidden;border:solid rgb(0,0,0) 1px; background-color:rgb(230,230,230);font-family:Arial,Helvetiva,Sans-Serif;filter:Alpha(Opacity=80); -moz-opacity:80%;"><table cellpadding="0" cellspacing="0">');
for(var p in navigation){
write('<tr style="cursor:pointer;" onclick="window.open(\''+navigation[p].url+'\',\''+((navigation[p].target)?navigation[p].target:"_self")+'\');"><td style="font-size:10px;width:12px;padding:2px;text-align:center;"><div style="border:solid rgb(0,0,0) 1px;background-color:rgb(40,40,40);color:white;">'+p+'</div></td><td style="font-size:10px;vertical-align:middle;">'+navigation[p].text+"</td></tr>");
}
write("</table></div>");
}
if (!document.all){ document.captureEvents(Event.KEYDOWN|Event.KEYUP); }
var keyboard=new Object();
window.onblur = function(){ document.getElementById("jojoxxkeynavigation").style.visibility="hidden"; for(var a in keyboard){ keyboard[a]=false; } }
document.onkeydown = function(e){
   if(!document.all){ event=e; }
   var key=(String.fromCharCode(event.keyCode))?String.fromCharCode(event.keyCode):"";
   if(event.keyCode>0){ keyboard[event.keyCode]=true; }
   if(event.ctrlKey){
      document.getElementById("jojoxxkeynavigation").style.visibility="visible";
   }
   if(event.ctrlKey&&(navigation[key.toUpperCase()]||navigation[key.toLowerCase()])){
      var obj=(navigation[key.toUpperCase()])?navigation[key.toUpperCase()]:navigation[key.toLowerCase()];
      window.open(obj.url,(obj.target)?obj.target:"_self");
      return false;
   }
}
document.onkeyup = function(e){
   if(!document.all){ event=e; }
   if(event.keyCode>0){ keyboard[event.keyCode]=false; }
   document.getElementById("jojoxxkeynavigation").style.visibility="hidden";
}
</script>

Kommentar

Scriptet låter besökaren navigera genom snabbtangenter. Håll ner [Ctrl]-knappen så kommer en meny fram som visar vilka val som finns. Skriv in länkarna i början av scriptet enligt exemplet i formatet:

navigation['snabbtangent']={ text:"Namn på sida", url:"url till sida", target:"target" };

,