July 8
Posizionamento di un codice JavaScript sul tuo sito web consente di utilizzare un menu dinamico, pop-up, come la navigazione del sito. Quando un utente fa clic destro in qualsiasi punto della pagina Web, viene visualizzato il menu pop-up con i link da cui scegliere. Facendo clic ovunque al di fuori del pop-up farà il menu scomparire. Questo permette all'utente di vedere il vostro menu, non importa quanto in basso nella pagina che ha fatto scorrere. È possibile configurare un codice di base JavaScript per creare questo menu a comparsa nella pagina Web.
1 Copiare il codice seguente:
<Script language = \ "javascript \">
<! -
var ie = document.all
var NS6 = document.getElementById &&! document.all
var isMenu = false
ANDARE
var menuSelObj = null
ANDARE
var overpopupmenu = false
ANDARE
Funzione mouseSelect (e)
{
var obj = NS6? e.target.parentNode: event.srcElement.parentElement
ANDARE
if (isMenu)
{
if (overpopupmenu == false)
{
isMenu = false
ANDARE
overpopupmenu = false
ANDARE
document.getElementById ( 'menudiv'). style.display = \ "none \"
ANDARE
return true
ANDARE
}
return true
ANDARE
}
return false
ANDARE
}
// MENÙ POPUP
Funzione ItemSelMenu (e)
{
var obj = NS6? e.target.parentNode: event.srcElement.parentElement;
menuSelObj = obj
ANDARE
if (NS6)
{
document.getElementById ( 'menudiv'). style.left = e.clientX + document.body.scrollLeft
ANDARE
document.getElementById ( 'menudiv'). style.top = e.clientY + document.body.scrollTop
ANDARE
} altro
{
document.getElementById ( 'menudiv'). style.pixelLeft = event.clientX + document.body.scrollLeft
ANDARE
document.getElementById ( 'menudiv'). style.pixelTop = event.clientY + document.body.scrollTop
ANDARE
}
document.getElementById ( 'menudiv'). style.display = \ "\"
ANDARE
document.getElementById ( 'item1'). style.backgroundColor = '# FFFFFF'
ANDARE
document.getElementById ( 'item2'). style.backgroundColor = '# FFFFFF'
ANDARE
document.getElementById ( 'item3'). style.backgroundColor = '# FFFFFF'
ANDARE
document.getElementById ( 'item4'). style.backgroundColor = '# FFFFFF'
ANDARE
isMenu = true
ANDARE
return false
ANDARE
}
document.onmousedown = mouseSelect
ANDARE
document.oncontextmenu = ItemSelMenu
ANDARE
// ->
</ Script>
2 Incolla questo codice tra i tag <head> e </ head> nel codice HTML della pagina Web.
3 copia questo codice:
<! --------------------- POPUP MENU ------------------------- ->
<Div id = \ style = "position: absolute; display: none; top: 0px; sinistra: 0px; z-index: 10000; \" "menudiv \" \ onmouseover = \ "javascript: overpopupmenu = true; \" onmouseout = \ "javascript: overpopupmenu = false; \">
<Table width = 82 cellspacing = 1 cellpadding = 0 bgcolor = lightgray>
<Tr> <td>
<table width=80 cellspacing=0 cellpadding=0>
<tr>
<td id=\"item1\" bgcolor=\"#FFFFFF\" width=\"80\" height=\"16\" onMouseOver=\"this.style.backgroundColor='#EFEFEF'\" onMouseOut=\"this.style.backgroundColor='#FFFFFF'\"> <a href=\"#\">Item1</a></td>
</tr>
<tr>
<td id=\"item2\" bgcolor=\"#FFFFFF\" width=\"80\" height=\"16\" onMouseOver=\"this.style.backgroundColor='#EFEFEF'\" onMouseOut=\"this.style.backgroundColor='#FFFFFF'\"> <a href=\"#\">Item2</a></td>
</tr>
<tr>
<td id=\"item3\" bgcolor=\"#FFFFFF\" width=\"80\" height=\"16\" onMouseOver=\"this.style.backgroundColor='#EFEFEF'\" onMouseOut=\"this.style.backgroundColor='#FFFFFF'\"> <a href=\"#\">Item3</a></td>
</tr>
<tr>
<td id=\"item4\" bgcolor=\"#ffffff\" width=\"80\" height=\"16\" onMouseOver=\"this.style.backgroundColor='#EFEFEF'\" onMouseOut=\"this.style.backgroundColor='#FFFFFF'\"> <a href=\"#\">Item4</a></td>
</tr>
</table>
</ Td> </ tr>
</ Table>
</ Div>
4 Incollare il codice tra i tag <body> </ body> di codice HTML della pagina Web. Non importa dove nella sezione corpo si incolla questo codice dal momento che il menu apparirà in modo dinamico ove il diritto-utente fa clic.
5 Configurare le voci di collegamento nel codice. Ad esempio, nel codice <a href=\"#\"> Item1 </a>, sostituire il "#" con l'URL del sito a cui si desidera collegare. Sostituire il "Item1" con il nome di quel collegamento.
6 Salvare la pagina Web modificato e caricarlo sul tuo host web per visualizzare il menu pop-up.