View Full Version : Código


tomassantos
09-05-2008, 20:58
Olá, tive a desenvolver este código

<ilayer width=400 height=32 name="dep1" bgColor="#E6E6FF"></ilayer><a href="google.pt" onMouseover="showit(1)"><font color="#000000">Tomás</font></a>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="google.pt" onMouseover="showit(0)">
<font color="#000000">Tomás2</font></a><ilayer width=400 height=32 name="dep1" bgColor="#E6E6FF"></p>
<layer name="dep2" width=400 height=32>
</layer>
</ilayer>
<div id="describe" style="background-color:#E6E6FF;width:192px;height:189px" onMouseover="clear_delayhide()" onMouseout="resetit(event)"></div>


<script language="JavaScript1.2">


var submenu=new Array()


submenu[1]='<a href="google.comt" onMouseover="showit(0)"><font color="#000000">1</font></a> <p> <a href="google.com" onMouseover="showit(0)"><font color="#000000">2</font></a> <p> <a href="google.com"><font color="#000000">3</font></a> <p> <a href="google.com"><font color="#000000">4</font>'

submenu[0]='<a href="google.com" onMouseover="showit(0)"><font color="#000000">5</font></a> <p> <a href="google.com" onMouseover="showit(0)"><font color="#000000">6</font></a> <p> <a href="google.com"><font color="#000000">7</font></a> <p> <a href="google.com"><font color="#000000">8</font>'


var delay_hide=700



var menuobj=document.getElementById? document.getElementById("describe") : document.all? document.all.describe : document.layers? document.dep1.document.dep2 : ""

function showit(which){
clear_delayhide()
thecontent=(which==-1)? "" : submenu[which]
if (document.getElementById||document.all)
menuobj.innerHTML=thecontent
else if (document.layers){
menuobj.document.write(thecontent)
menuobj.document.close()
}
}

function resetit(e){
if (document.all&&!menuobj.contains(e.toElement))
delayhide=setTimeout("showit(-1)",delay_hide)
else if (document.getElementById&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhide=setTimeout("showit(-1)",delay_hide)
}

function clear_delayhide(){
if (window.delayhide)
clearTimeout(delayhide)
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

</script>



Aqui está: http://tomassantos.do.sapo.pt/botoes.htm


Mas queria que aquela janela que aparece esteja: A do 'Tomas' por baixo desta e a do 'Tomás2' em baixo desta'

Não percebi como isso se faz, pois estou a começar a trabalhar com linguagens

Podiam-me dizer o código?


Obrigado.

tomassantos
09-05-2008, 22:15
Nínguem me pode ajudar?

Parafuso
10-05-2008, 02:19
Será isto que pretendes?!

Um conselho para quem está a começar a programar, estrutura o teu código com tabs, facilita a interpretação e a programação num editor.


<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Tomás Tomás2</title>
</head>

<body>

<ilayer width=400 height=32 name="dep1" bgColor="#E6E6FF"></ilayer>
<a href="google.pt" onMouseover="showit(1)"><font color="#000000">Tomás</font></a>
<p>&nbsp;</p>
<div id="describe1" style="background-color:#E6E6FF;width:192px;height:189px" onMouseover="clear_delayhide()" onMouseout="resetit(event)"></div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<a href="google.pt" onMouseover="showit(0)"><font color="#000000">Tomás2</font></a>
<ilayer width=400 height=32 name="dep2" bgColor="#E6E6FF"></ilayer></p>

<div id="describe2" style="background-color:#E6E6FF;width:192px;height:189px" onMouseover="clear_delayhide()" onMouseout="resetit(event)"></div>


<script language="JavaScript1.2">


var submenu=new Array()


submenu[1]='<a href="google.comt" onMouseover="showit(1)"><font color="#000000">1</font></a> <p> <a href="google.com" onMouseover="showit(1)"><font color="#000000">2</font></a> <p> <a href="google.com"><font color="#000000">3</font></a> <p> <a href="google.com"><font color="#000000">4</font>'

submenu[0]='<a href="google.com" onMouseover="showit(0)"><font color="#000000">5</font></a> <p> <a href="google.com" onMouseover="showit(0)"><font color="#000000">6</font></a> <p> <a href="google.com"><font color="#000000">7</font></a> <p> <a href="google.com"><font color="#000000">8</font>'


var delay_hide=700

var menuobj1=document.getElementById? document.getElementById("describe1") : document.all? document.all.describe1 : document.layers? document.dep1.document.dep1 : ""
var menuobj2=document.getElementById? document.getElementById("describe2") : document.all? document.all.describe2 : document.layers? document.dep2.document.dep2 : ""

function showit(which)
{
clear_delayhide()

thecontent=(which==-1)? "" : submenu[which]
if (which == 1)
menuobj1.innerHTML=thecontent
else if (document.layers)
{
menuobj1.document.write(thecontent)
menuobj1.document.close()
}
if (which == 0)
menuobj2.innerHTML=thecontent
else if (document.layers)
{
menuobj2.document.write(thecontent)
menuobj2.document.close()
}
}


function resetit(e)
{
if (document.all&&!menuobj.contains(e.toElement))
delayhide=setTimeout("showit(-1)",delay_hide)
else if (document.getElementById&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhide=setTimeout("showit(-1)",delay_hide)
}

function clear_delayhide()
{
if (window.delayhide)
clearTimeout(delayhide)
}

function contains_ns6(a, b)
{
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

</script>
&nbsp;
</body>

</html>

tomassantos
10-05-2008, 15:27
Ya era isso, obrigado.


Um conselho para quem está a começar a programar, estrutura o teu código com tabs, facilita a interpretação e a programação num editor.

Como assim 'tabs'?

slack_guy
10-05-2008, 15:29
Por curiosidade, para que precisas da <ilayer>?

tomassantos
10-05-2008, 15:38
Não preciso.

Parafuso
10-05-2008, 16:50
Ya era isso, obrigado.

Como assim 'tabs'?

Usa a tecla "tab" para dar espaço, penso que me fiz entender?! ;)

tomassantos
10-05-2008, 16:52
Ok, pensava que era uma coisa qualquer de programar.

fil79
10-05-2008, 19:22
Ok, pensava que era uma coisa qualquer de programar.


a isso se chama identação que com o tempo vais começar a usar..
http://pt.wikipedia.org/wiki/Indenta%C3%A7%C3%A3o