olá.. tenho dois scriots q funcionam separadamente perfeitamente mas se eu os coloco junto na mesma página um deles nao funciona...
o primeiro q sempre funciona eh esse:
==================== menu.js ============================
function IEHoverPseudo() {
var navItems = document.getElementById("primary-nav").getElementsByTagName("li");
for (var i=0; i<navItems.length; i++) {
if(navItems[i].className == "menuparent") {
navItems[i].onmouseover=function() { this.className += " over"; }
navItems[i].onmouseout=function() { this.className = "menuparent"; }
}
}
}
window.onload = IEHoverPseudo;
=====================================================
o segundo q so funciona isoladamente eh esse:
==================== banner.js ==========================
var banners = new Array(
'/new/quimica.jpg',
'/new/industria.gif',
'/new/uvas.gif',
'/new/bolhas1.gif');
var linx = new Array(
'#',
'#',
'#',
'#');
var old = 0;
var current = 0;
function init()
{
if (!document.images) return
while (current == old)
{
current = Math.floor(Math.random()*banners.length);
}
old = current;
document.images['banner'].src = banners[current];
setTimeout('init()',3000);
}
function sendPage()
{
location.href = linx[current];
}
======================================================
bom lá na pagina principal chamo eles assim ó ..
<html>
<head>
<script type="text/javascript" src="banner.js"> </SCRIPT>
<script type="text/javascript" src="menu.js"> </SCRIPT>
<head>

Incompatibilidade Entre Js's ,,,
Started By kurumim, 08/03/2006, 17:29
5 replies to this topic
#1
Posted 08/03/2006, 17:29
"Paz, Amor e Software Livre - Linux"
#2
Posted 09/03/2006, 11:27
O segundo, do jeito que está, não faz nada, nunca.
#3
Posted 09/03/2006, 14:19
sim sim .. eh q faltou informar a parte principal do codigo.. q chama os scripts... rssrrs
ps: tirei as partes desnecessárias..
<html>
<head>
<link rel="stylesheet" type="text/css" href="./menu_h.css">
<link rel="stylesheet" type="text/css" href="./menu_left.css">
<script type="text/javascript" src="banner.js"> </SCRIPT>
<script type="text/javascript" src="menu.js"> </SCRIPT>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#E0E0E0">
<center>
<div id="Layer1" style="position:relative; left:0px; top:0px; width:778px; height:600px; z-index:0; background-image: url(home.gif); layer-background-image: url(home.gif); border: 1px none #000000">
<!-- BANNERS ROTATIVOS -->
<div id="banner"
style="position: absolute; left: 600px; top: 300px;
width: 173px; height:60px; z-index:1;
background-image: url(/new/quimica.jpg); layer-background-image: url(/new/quimica.jpg);">
<body onload="init()">
<a href="java script:sendpage()">
<img src="" name="banner" width=173px height=90px border=0>
</a>
</body>
</div>
</div>
</center>
</body>
</html>
[/B]
ps: tirei as partes desnecessárias..

<html>
<head>
<link rel="stylesheet" type="text/css" href="./menu_h.css">
<link rel="stylesheet" type="text/css" href="./menu_left.css">
<script type="text/javascript" src="banner.js"> </SCRIPT>
<script type="text/javascript" src="menu.js"> </SCRIPT>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#E0E0E0">
<center>
<div id="Layer1" style="position:relative; left:0px; top:0px; width:778px; height:600px; z-index:0; background-image: url(home.gif); layer-background-image: url(home.gif); border: 1px none #000000">
<!-- BANNERS ROTATIVOS -->
<div id="banner"
style="position: absolute; left: 600px; top: 300px;
width: 173px; height:60px; z-index:1;
background-image: url(/new/quimica.jpg); layer-background-image: url(/new/quimica.jpg);">
<body onload="init()">
<a href="java script:sendpage()">
<img src="" name="banner" width=173px height=90px border=0>
</a>
</body>
</div>
</div>
</center>
</body>
</html>
[/B]
"Paz, Amor e Software Livre - Linux"
#4
Posted 09/03/2006, 14:25
Dois bodys? Uma div antes do body?
O problema é simples e claro, as duas funções são ignorantes e se instalam no evento "load" descartando o que já esteja lá.
A solução é mais simples ainda, faça uma função apenas, que chamará as duas funções de inicialização e, daí chame esta nova função on load.
O problema é simples e claro, as duas funções são ignorantes e se instalam no evento "load" descartando o que já esteja lá.
A solução é mais simples ainda, faça uma função apenas, que chamará as duas funções de inicialização e, daí chame esta nova função on load.
#5
Posted 09/03/2006, 14:41
bah valeu mesmo 
:D ... muta gracias..
funcionou .. chamei a função " init();" de dentro do javascript q uso para o menu.. q eh esse aqui.. :
============ menu.js ===================================
function IEHoverPseudo() {
init();
var navItems = document.getElementById("primary-nav").getElementsByTagName("li");
for (var i=0; i<navItems.length; i++) {
if(navItems[i].className == "menuparent") {
navItems[i].onmouseover=function() { this.className += " over"; }
navItems[i].onmouseout=function() { this.className = "menuparent"; }
}
}
}
window.onload = IEHoverPseudo;
=====================================================
ah e so pra esclarecer bem.. entom não devo nunca usar um body dentro de outro.. chamando uma função con o onload.. .
chamo todos os JS atraves de um unico scritp principal.. isso ??


funcionou .. chamei a função " init();" de dentro do javascript q uso para o menu.. q eh esse aqui.. :
============ menu.js ===================================
function IEHoverPseudo() {
init();
var navItems = document.getElementById("primary-nav").getElementsByTagName("li");
for (var i=0; i<navItems.length; i++) {
if(navItems[i].className == "menuparent") {
navItems[i].onmouseover=function() { this.className += " over"; }
navItems[i].onmouseout=function() { this.className = "menuparent"; }
}
}
}
window.onload = IEHoverPseudo;
=====================================================
ah e so pra esclarecer bem.. entom não devo nunca usar um body dentro de outro.. chamando uma função con o onload.. .
chamo todos os JS atraves de um unico scritp principal.. isso ??
"Paz, Amor e Software Livre - Linux"
#6
Posted 09/03/2006, 15:29
Sobre a dúvida 1.
Toda página só possui um <body>.
Sobre a dúvida 2.
É uma forma válida sim.
Toda página só possui um <body>.
Sobre a dúvida 2.
É uma forma válida sim.
1 user(s) are reading this topic
0 membro(s), 1 visitante(s) e 0 membros anônimo(s)