Dato un file javascript con una funzione e il link per richiamarla come faccio a inserire una variabile?
Ad esempio, come faccio nella funzione function moveOffSelector() a specificargli con una variabile il componente da muovere ? Le altre modifiche poi le faccio da me?
Dove e come devo dichiarare le variabili? e nel link cosa devo modificare
Codice nella pagina html
file javascript
codice:
Show ="no";
// Set OffX in pixels to a negative number
// somewhat larger than the width of the menu.
var OffX = -600;
// Set the PosX and PosY variables
// to the location on the screen where the
// menu should position (in pixels) when stopped.
var PosX = (screen.width-screen.width*0.88)/2+250; //orizzontale
var PosY = 5;//verticale
// Usually, use the settings shown; but you can
// change the speed and the increment of motion
// across the screen, below.
var speed = 0;
var increment = 2;
var incrementNS4 = 5; // for slower NS4 browsers
// do not edit below this line
// ===========================
var is_NS = navigator.appName=="Netscape";
var is_Ver = parseInt(navigator.appVersion);
var is_NS4 = is_NS&&is_Ver>=4&&is_Ver<5;
var is_NS5up = is_NS&&is_Ver>=5;
var MenuX=OffX;
var SelX=PosX;
var sPosX=PosX;
var sOffX=OffX;
if (Show=="yes"){
sPosX=OffX;
sOffX=PosX;
MenuX=sOffX;
SelX=sPosX;
}
if (is_NS4){
increment=incrementNS4;
Lq="document.layers.";
Sq="";
eval(Lq+'menuSelect'+Sq+'.left=sPosX');
eval(Lq+'menuShow'+Sq+'.left=sOffX');
eval(Lq+'menuSelect'+Sq+'.top=PosY');
eval(Lq+'menuShow'+Sq+'.top=PosY');
}else{
Lq="document.all.";
Sq=".style";
document.getElementById('menuSelect').style.left=sPosX+"px";
document.getElementById('menuShow').style.left=sOffX+"px";
document.getElementById('menuSelect').style.top=PosY+"px";
document.getElementById('menuShow').style.top=PosY+"px";
}
.............. altre funzioni che poi modifico io rimosse
QUI LA FUNZIONE
function moveOffSelector(){
if (SelX>OffX){
SelX=SelX-increment;
if (is_NS5up){
document.getElementById('menuSelect').style.left=SelX+"px";
}else{
eval(Lq+'menuSelect'+Sq+'.left=SelX');
}
setTimeout('moveOffSelector()',speed);
}
}