Click to See Complete Forum and Search --> : setting target in this script


jente
12-11-2003, 03:06 AM
Hello y'all,

I have to adjust code from a website. One problem I have (and can't solve) is the following. I have a script that goes to a specified link if you press par example A. But I work with frames, and I don't know how to set target for those links... My experience with javascript is zero :). Does anyone has an idea?

Here's the script:



<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->


<!--
// Please do not edit this script tag.
var aKeyArray = new Array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','O');
var aLocationArray = new Array('firma.php','personeel.php','hdl.php','daisy.php','nieuws.php','lowvision.php','printers.php', 'menu pages/prod_BrailleNota.htm','menu pages/prod_Brailledisplays.htm','menu pages/prod_SchermUitlees.htm','spraakoutput.php','voorleestoestel.php','contacteer.htm','menu pages/tech/techmenu.htm', 'links.php','http://www.integra-belgium.com/sitetobe/index.html');

function doHotKey(e){
for(i=0; i < aKeyArray.length; i++){
if(document.layers){ // NN4+
if (aKeyArray[i] == String.fromCharCode(e.which)){
window.location = aLocationArray[i],'inhoud';
}
} else if(document.all){ // IE4+
if(aKeyArray[i] == String.fromCharCode(event.keyCode)){
window.location = aLocationArray[i];
}
} else if(document.getElementById){ // NN6
if(aKeyArray[i] == String.fromCharCode(e.which)){
window.location = aLocationArray[i];
}
}
}
}


if(document.layers){
document.captureEvents(Event.KEYPRESS);
}
document.onkeypress=doHotKey;
//-->



THis is no PHP offcourse, but I wanted to give some color ;)

jente
12-11-2003, 03:46 AM
How nice it is to solve your own problems ;)

I changed

window.location

to

parent.framename.location

and yeah, it works :)

Thnx anyway,

J

fredmv
12-11-2003, 04:08 AM
Why are you using JavaScript to provide that kind of funcionality? Accesskeys do the exact same thing and work regardless if the client's browser supports JavaScript or not.

jente
12-11-2003, 04:14 AM
with accesskeys you have to press enter, no?

fredmv
12-11-2003, 04:17 AM
Only under IE (another example of why it sucks). Most other browsers, Mozilla for example, allow you to press the ALT + key key sequence and the page is loaded.