...

View Full Version : Conflict Java scripts



Fireangel
12-08-2004, 08:21 PM
Hello All!
I would like to ask for a litlle help ..
I add in my index.html a new java script and now my arrays dont work!
When I put onLoad="start()" inside the body my hierarhical menus do not work.. any ideas?





<!DOCTYPE HTML PUBLIC "-//W3C//Dtd HTML 4.0 transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<html>
<head>
<title>X</title>

<!-- ========================================== Start Meta Tags ===================================== -->

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<!-- ========================================== End Meta Tags ===================================== -->

<!-- ========================================== Start of Java Scripts ===================================== -->
<SCRIPT>
<!--
if (navigator.appName.indexOf("Microsoft")!=-1)
{
document.write("<link rel=STYLESHEET href=styles/styles.css type=text/css>")
}
else
{
document.write("<link rel=STYLESHEET href=styles/styles.css type=text/css>")
}
//-->
</SCRIPT>

<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
NS4 = (document.layers);
NS6 = (document.getElementbyId);
IE4 = (document.all);
ver4 = (NS4 || IE4);
IE5 = (IE4 && navigator.appVersion.indexOf("5.")!=-1);
isMac = (navigator.appVersion.indexOf("Mac") != -1);
isMenu = (NS4 || (IE4 && !isMac) || (IE5 && isMac));
function popUp(){return};
function popDown(){return};
if (!ver4) event=null;
//-->
</SCRIPT>

<SCRIPT LANGUAGE="JavaScript1.2" TYPE="text/javascript">
<!--
if (isMenu) {
menuVersion = 3;
menuWidth = 130;
childOverlap = null;
childOffset = null;
perCentOver = null;
secondsVisible = .2;
fntCol = "#F8F8F8";
fntSiz = "8";
fntBold = false;
fntItal = false;
fntFam = "Verdana, Arial Greek, Helvetica";
backCol = "#0069A3";
overCol = "#ff0000";
overFnt = "#f9efcc";
borWid = 1;
borCol = "#000000";
borSty = "solid";
itemPad = 2;
imgSrc = "images/tri_1.gif";
imgSiz = 10;
separator = 1;
separatorCol = "#f9efcc";
isFrames = false;
keepHilite = false;
clickStart = false;
clickKill = false;
}
//-->
</SCRIPT>

<SCRIPT LANGUAGE="JavaScript1.2" TYPE="text/javascript">
<!--
if ((isMenu) && (navigator.appName == "Microsoft Internet Explorer")) {
document.write("<SCRIPT LANGUAGE=JavaScript1.2 SRC=js/hierArrays.js TYPE=text/javascript><\/SCRIPT>");
document.write("<SCRIPT LANGUAGE=JavaScript1.2 SRC=js/hierMenus.js TYPE=text/javascript><\/SCRIPT>");
}

if ((isMenu) && (navigator.appName == "Netscape")) {
document.write("<SCRIPT LANGUAGE='JavaScript1.2' SRC='js/hierArrays_ns.js' TYPE='text/javascript'><\/SCRIPT>");
document.write("<SCRIPT LANGUAGE='JavaScript1.2' SRC='js/hierMenus.js' TYPE='text/javascript'><\/SCRIPT>");
}
//-->
</SCRIPT>


<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
//slider's width
var swidth=120

//slider's height
var sheight=100

//slider's speed
var sspeed=2

//messages: change to your own; use as many as you'd like; set up Hyperlinks to URLs as you normally do: <a target=... href="... URL ...">..message..</a>
var singletext=new Array()
singletext[0]='<div align="center"><font face=Verdana,Arial size=2px color="#0069A2"><b>College</b><br>Training <b>Red</b><br>This message may use <b><u>Hyperlinks</u></b></div></FONT>'
singletext[1]='<div align="center"><font face=Arial size=3 color="#000000">Use this for announcements<br>or even <font color="#FFFF00"><b><i>images</i></b><p><img src="/img/1.gif" width="100" height="39" border="0"></font></div>'
singletext[2]='<div align="center"><font face=Arial size=3 color="#000000">This is great!<br>You can use <i>all</i> the <b>basic</b><br><b>HTML codes</b></font></div>'
singletext[3]='<div align="center"><font face=Arial size=3 color="#000000"><b>JavaScript Source</b><br>A "cut & paste" JavaScript library<br>with <font color="red"><b>tons</b></font> of free JavaScripts!<p><img src="/img/1.gif" width="100" height="39" border="0"></font></div>'
if (singletext.length>1)
i=1
else
i=0
function start(){
if (document.all){
ieslider1.style.top=sheight
iemarquee(ieslider1)
}
else if (document.layers){
document.ns4slider.document.ns4slider1.top=sheight
document.ns4slider.document.ns4slider1.visibility='show'
ns4marquee(document.ns4slider.document.ns4slider1)
}
else if (document.getElementById&&!document.all){
document.getElementById('ns6slider1').style.top=sheight
ns6marquee(document.getElementById('ns6slider1'))
}
}
function iemarquee(whichdiv){
iediv=eval(whichdiv)
if (iediv.style.pixelTop>0&&iediv.style.pixelTop<=sspeed){
iediv.style.pixelTop=0
setTimeout("iemarquee(iediv)",100)
}
if (iediv.style.pixelTop>=sheight*-1){
iediv.style.pixelTop-=sspeed
setTimeout("iemarquee(iediv)",100)
}
else{
iediv.style.pixelTop=sheight
iediv.innerHTML=singletext[i]
if (i==singletext.length-1)
i=0
else
i++
}
}
function ns4marquee(whichlayer){
ns4layer=eval(whichlayer)
if (ns4layer.top>0&&ns4layer.top<=sspeed){
ns4layer.top=0
setTimeout("ns4marquee(ns4layer)",100)
}
if (ns4layer.top>=sheight*-1){
ns4layer.top-=sspeed
setTimeout("ns4marquee(ns4layer)",100)
}
else{
ns4layer.top=sheight
ns4layer.document.write(singletext[i])
ns4layer.document.close()
if (i==singletext.length-1)
i=0
else
i++
}
}
function ns6marquee(whichdiv){
ns6div=eval(whichdiv)
if (parseInt(ns6div.style.top)>0&&parseInt(ns6div.style.top)<=sspeed){
ns6div.style.top=0
setTimeout("ns6marquee(ns6div)",100)
}
if (parseInt(ns6div.style.top)>=sheight*-1){
ns6div.style.top=parseInt(ns6div.style.top)-sspeed
setTimeout("ns6marquee(ns6div)",100)
}
else{
ns6div.style.top=sheight
ns6div.innerHTML=singletext[i]
if (i==singletext.length-1)
i=0
else
i++
}
}
// End -->
</script>





<!-- ========================================== End of Java Scripts ===================================== -->



</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" background="images/back.gif" onLoad="start()">

<table id="Table_01" width="750" height="580" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2">
<img src="images/plus_01.jpg" width="750" height="164" alt="" usemap="#topmenu" border="0"></td>
</tr>
<tr>
<td valign="top">
<img src="images/plus_02.jpg" width="138" height="225" alt="" usemap="#menus" border="0"></td>
<td rowspan="2">


</td>
</tr>
<tr>
<td>

<!-- Here goes the text bla bla -->

</td>
</tr>
</table>

<!-- Image Map Starts Here -->

<map name="menus">
<area alt="" coords="6,2,120,25" onmouseover="popUp('elMenu2',event)" onmouseout="popDown('elMenu2')" onClick="return false">
<area alt="" coords="6,29,120,52" onmouseover="popUp('elMenu1',event)" onmouseout="popDown('elMenu1')" onClick="return false">
<area alt="" coords="7,56,125,81" onmouseover="popUp('elMenu3',event)" onmouseout="popDown('elMenu3')" onClick="return false">
<area alt="" coords="6,83,124,104" onmouseover="popUp('elMenu4',event)" onmouseout="popDown('elMenu4')" onClick="return false">
<area alt="" coords="7,110,124,133" onmouseover="popUp('elMenu5',event)" onmouseout="popDown('elMenu5')" onClick="return false">
<area alt="" coords="6,138,124,159" onmouseover="popUp('elMenu6',event)" onmouseout="popDown('elMenu6')" onClick="return false">
<area alt="" coords="9,179,107,199" onmouseover="popUp('elMenu7',event)" onmouseout="popDown('elMenu7')" onClick="return false">
</map>

<map name="topmenu">
<area alt="redhat" coords="180,105,254,121" href="#">
<area alt="training" coords="291,110,368,129" href="#">
<area alt="Rhdocs" coords="403,126,482,146" href="#">
<area alt="WhichRh" coords="461,103,607,120" href="#">
</map>


<!-- Image Map Ends Here -->


<div id="date" style="position:absolute; width:200; height:18; left:83; top:137; z-index:3; visibility:visible;">

<SCRIPT LANGUAGE="JavaScript1.2">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var months=new Array(13);
months[1]="January";
months[2]="February";
months[3]="March";
months[4]="April";
months[5]="May";
months[6]="June";
months[7]="July";
months[8]="August";
months[9]="September";
months[10]="October";
months[11]="November";
months[12]="December";
var time=new Date();
var lmonth=months[time.getMonth() + 1];
var date=time.getDate();
var year=time.getYear();
if (year < 2000) // Y2K Fix, Isaac Powell
year = year + 1900; // http://onyx.idbsu.edu/~ipowell
document.write("<center>" + lmonth + " ");
document.write(date + ", " + year + "</center>");
// End -->
</SCRIPT>


</div>

<div align="center">
<span style="borderWidth:1; borderColor:red; width:125; height:105; background:#ffffff">
<ilayer id="ns4slider" width="&{swidth};" height="&{sheight};">
<layer id="ns4slider1" height="&{sheight};" onmouseover="sspeed=0;" onmouseout="sspeed=2">
<script language="JavaScript">
if (document.layers)
document.write(singletext[0])
</script>
</layer></ilayer>
<script language="JavaScript">
if (document.all){
document.writeln('<div style="position:relative;overflow:hidden;width:'+swidth+';height:'+sheight+';clip:rect(0 '+swidth+' '+sheight+' 0);border:1 solid white;" onmouseover="sspeed=0;" onmouseout="sspeed=2">')
document.writeln('<div id="ieslider1" style="position:relative;width:'+swidth+';">')
document.write(singletext[0])
document.writeln('</div></div>')
}
if(document.getElementById&&!document.all){
document.writeln('<div style="position:relative;overflow:hidden;width:'+swidth+';height:'+sheight+';clip:rect(0 '+swidth+' '+sheight+' 0);border:1px solid white;" onmouseover="sspeed=0;" onmouseout="sspeed=2">')
document.writeln('<div id="ns6slider1" style="position:relative;width:'+swidth+';">')
document.write(singletext[0])
document.writeln('</div></div>')
}
</script></span>
</div>
</body>
</html>undefined

Badman3k
12-08-2004, 10:21 PM
Is there any chance you could also post the js/hierArrays.js and js/hierMenu.js files too. Having a bit of trouble testing this when the thing wont work without them. (N.B. please use the code tags, when posting scripts, makes it easier to read :))

Cheers

Fireangel
12-08-2004, 10:40 PM
Dear Badman3K,

Thank you very much for your help, you can download this files you ask :
http://byron.fireman.gr/js.zip
I include both files there ! Give it a try , waiting the results thank you so much. :thumbsup:

John

Badman3k
12-09-2004, 12:03 AM
Well I've managed to get both the Menu system and the scrolling text to work. However it's more of a work around than a true solution.

To make it work I've done two things:
1) I've changed the array singletext to randomMessages
2) Called the start() function later on in the page (NOT onLoad)
See the code highlighted in RED for the changes



<!DOCTYPE HTML PUBLIC "-//W3C//Dtd HTML 4.0 transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<html>
<head>
<title>X</title>

<!-- ========================================== Start Meta Tags ===================================== -->

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<!-- ========================================== End Meta Tags ===================================== -->

<!-- ========================================== Start of Java Scripts ===================================== -->
<SCRIPT>
<!--
if (navigator.appName.indexOf("Microsoft")!=-1)
{
document.write("<link rel=STYLESHEET href=styles/styles.css type=text/css>")
}
else
{
document.write("<link rel=STYLESHEET href=styles/styles.css type=text/css>")
}
//-->
</SCRIPT>

<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
NS4 = (document.layers);
NS6 = (document.getElementbyId);
IE4 = (document.all);
ver4 = (NS4 || IE4);
IE5 = (IE4 && navigator.appVersion.indexOf("5.")!=-1);
isMac = (navigator.appVersion.indexOf("Mac") != -1);
isMenu = (NS4 || (IE4 && !isMac) || (IE5 && isMac));
function popUp(){return};
function popDown(){return};
if (!ver4) event=null;
//-->
</SCRIPT>

<SCRIPT LANGUAGE="JavaScript1.2" TYPE="text/javascript">
<!--
if (isMenu) {
menuVersion = 3;
menuWidth = 130;
childOverlap = null;
childOffset = null;
perCentOver = null;
secondsVisible = .2;
fntCol = "#F8F8F8";
fntSiz = "8";
fntBold = false;
fntItal = false;
fntFam = "Verdana, Arial Greek, Helvetica";
backCol = "#0069A3";
overCol = "#ff0000";
overFnt = "#f9efcc";
borWid = 1;
borCol = "#000000";
borSty = "solid";
itemPad = 2;
imgSrc = "images/tri_1.gif";
imgSiz = 10;
separator = 1;
separatorCol = "#f9efcc";
isFrames = false;
keepHilite = false;
clickStart = false;
clickKill = false;
}
//-->
</SCRIPT>

<SCRIPT LANGUAGE="JavaScript1.2" TYPE="text/javascript">
<!--
if ((isMenu) && (navigator.appName == "Microsoft Internet Explorer")) {
document.write("<SCRIPT LANGUAGE=JavaScript1.2 SRC=js/hierArrays.js TYPE=text/javascript><\/SCRIPT>");
document.write("<SCRIPT LANGUAGE=JavaScript1.2 SRC=js/hierMenus.js TYPE=text/javascript><\/SCRIPT>");
}

if ((isMenu) && (navigator.appName == "Netscape")) {
document.write("<SCRIPT LANGUAGE='JavaScript1.2' SRC='js/hierArrays_ns.js' TYPE='text/javascript'><\/SCRIPT>");
document.write("<SCRIPT LANGUAGE='JavaScript1.2' SRC='js/hierMenus.js' TYPE='text/javascript'><\/SCRIPT>");
}

//-->
</SCRIPT>


<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
//slider's width
var swidth=120

//slider's height
var sheight=100

//slider's speed
var sspeed=2

//messages: change to your own; use as many as you'd like; set up Hyperlinks to URLs as you normally do: <a target=... href="... URL ...">..message..</a>
var randomMessages=new Array()
randomMessages[0]='<div align="center"><font face=Verdana,Arial size=2px color="#0069A2"><b>City College</b><br>Training <b>Red Hat</b><br>This message may use <b><u>Hyperlinks</u></b></div></FONT>'
randomMessages[1]='<div align="center"><font face=Arial size=3 color="#000000">Use this for announcements<br>or even <font color="#FFFF00"><b><i>images</i></b><p><img src="/img/1.gif" width="100" height="39" border="0"></font></div>'
randomMessages[2]='<div align="center"><font face=Arial size=3 color="#000000">This is great!<br>You can use <i>all</i> the <b>basic</b><br><b>HTML codes</b></font></div>'
randomMessages[3]='<div align="center"><font face=Arial size=3 color="#000000"><b>JavaScript Source</b><br>A "cut & paste" JavaScript library<br>with <font color="red"><b>tons</b></font> of free JavaScripts!<p><img src="/img/1.gif" width="100" height="39" border="0"></font></div>'
if (randomMessages.length>1)
i=1
else
i=0

function start(){
if (document.all){
ieslider1.style.top=sheight
iemarquee(ieslider1)
}
else if (document.layers){
document.ns4slider.document.ns4slider1.top=sheight
document.ns4slider.document.ns4slider1.visibility='show'
ns4marquee(document.ns4slider.document.ns4slider1)
}
else if (document.getElementById&&!document.all){
document.getElementById('ns6slider1').style.top=sheight
ns6marquee(document.getElementById('ns6slider1'))
}
}
function iemarquee(whichdiv){
iediv=eval(whichdiv)
if (iediv.style.pixelTop>0&&iediv.style.pixelTop<=sspeed){
iediv.style.pixelTop=0
setTimeout("iemarquee(iediv)",100)
}
if (iediv.style.pixelTop>=sheight*-1){
iediv.style.pixelTop-=sspeed
setTimeout("iemarquee(iediv)",100)
}
else{
iediv.style.pixelTop=sheight
iediv.innerHTML=randomMessages[i]
if (i==randomMessages.length-1)
i=0
else
i++
}
}
function ns4marquee(whichlayer){
ns4layer=eval(whichlayer)
if (ns4layer.top>0&&ns4layer.top<=sspeed){
ns4layer.top=0
setTimeout("ns4marquee(ns4layer)",100)
}
if (ns4layer.top>=sheight*-1){
ns4layer.top-=sspeed
setTimeout("ns4marquee(ns4layer)",100)
}
else{
ns4layer.top=sheight
ns4layer.document.write(randomMessages[i])
ns4layer.document.close()
if (i==randomMessages.length-1)
i=0
else
i++
}
}
function ns6marquee(whichdiv){
ns6div=eval(whichdiv)
if (parseInt(ns6div.style.top)>0&&parseInt(ns6div.style.top)<=sspeed){
ns6div.style.top=0
setTimeout("ns6marquee(ns6div)",100)
}
if (parseInt(ns6div.style.top)>=sheight*-1){
ns6div.style.top=parseInt(ns6div.style.top)-sspeed
setTimeout("ns6marquee(ns6div)",100)
}
else{
ns6div.style.top=sheight
ns6div.innerHTML=randomMessages[i]
if (i==randomMessages.length-1)
i=0
else
i++
}
}
// End -->
</script>





<!-- ========================================== End of Java Scripts ===================================== -->



</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" background="images/back.gif">

<table id="Table_01" width="750" height="580" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2">
<img src="images/plus_01.jpg" width="750" height="164" alt="" usemap="#topmenu" border="0"></td>
</tr>
<tr>
<td valign="top">
<img src="images/plus_02.jpg" width="138" height="225" alt="" usemap="#menus" border="0"></td>
<td rowspan="2">


</td>
</tr>
<tr>
<td>

<!-- Here goes the text bla bla -->

</td>
</tr>
</table>

<!-- Image Map Starts Here -->
<map name="menus">
<area alt="" coords="6,2,120,25" onmouseover="popUp('elMenu2',event)" onmouseout="popDown('elMenu2')" onClick="return false">
<area alt="" coords="6,29,120,52" onmouseover="popUp('elMenu1',event)" onmouseout="popDown('elMenu1')" onClick="return false">
<area alt="" coords="7,56,125,81" onmouseover="popUp('elMenu3',event)" onmouseout="popDown('elMenu3')" onClick="return false">
<area alt="" coords="6,83,124,104" onmouseover="popUp('elMenu4',event)" onmouseout="popDown('elMenu4')" onClick="return false">
<area alt="" coords="7,110,124,133" onmouseover="popUp('elMenu5',event)" onmouseout="popDown('elMenu5')" onClick="return false">
<area alt="" coords="6,138,124,159" onmouseover="popUp('elMenu6',event)" onmouseout="popDown('elMenu6')" onClick="return false">
<area alt="" coords="9,179,107,199" onmouseover="popUp('elMenu7',event)" onmouseout="popDown('elMenu7')" onClick="return false">
</map>

<map name="topmenu">
<area alt="redhat" coords="180,105,254,121" href="#">
<area alt="training" coords="291,110,368,129" href="#">
<area alt="Rhdocs" coords="403,126,482,146" href="#">
<area alt="WhichRh" coords="461,103,607,120" href="#">
</map>


<!-- Image Map Ends Here -->


<div id="date" style="position:absolute; width:200; height:18; left:83; top:137; z-index:3; visibility:visible;">

<SCRIPT LANGUAGE="JavaScript1.2">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var months=new Array(13);
months[1]="January";
months[2]="February";
months[3]="March";
months[4]="April";
months[5]="May";
months[6]="June";
months[7]="July";
months[8]="August";
months[9]="September";
months[10]="October";
months[11]="November";
months[12]="December";
var time=new Date();
var lmonth=months[time.getMonth() + 1];
var date=time.getDate();
var year=time.getYear();
if (year < 2000) // Y2K Fix, Isaac Powell
year = year + 1900; // http://onyx.idbsu.edu/~ipowell
document.write("<center>" + lmonth + " ");
document.write(date + ", " + year + "</center>");
// End -->
</SCRIPT>


</div>

<div align="center">
<span style="borderWidth:1; borderColor:red; width:125; height:105; background:#ffffff">
<ilayer id="ns4slider" width="&{swidth};" height="&{sheight};">
<layer id="ns4slider1" height="&{sheight};" onmouseover="sspeed=0;" onmouseout="sspeed=2">
<script language="JavaScript">
if (document.layers)
document.write(randomMessages[0])
</script>
</layer></ilayer>
<script language="JavaScript">
if (document.all){
document.writeln('<div style="position:relative;overflow:hidden;width:'+swidth+' ;height:'+sheight+';clip:rect(0 '+swidth+' '+sheight+' 0);border:1 solid white;" onmouseover="sspeed=0;" onmouseout="sspeed=2">')
document.writeln('<div id="ieslider1" style="position:relative;width:'+swidth+';">')
document.write(randomMessages[0])
document.writeln('</div></div>')
}
if(document.getElementById&&!document.all){
document.writeln('<div style="position:relative;overflow:hidden;width:'+swidth+' ;height:'+sheight+';clip:rect(0 '+swidth+' '+sheight+' 0);border:1px solid white;" onmouseover="sspeed=0;" onmouseout="sspeed=2">')
document.writeln('<div id="ns6slider1" style="position:relative;width:'+swidth+';">')
document.write(randomMessages[0])
document.writeln('</div></div>')
}
start();
</script></span>
</div>
</body>
</html>


:thumbsup:

Just as a side note, I could only get the menu system to work in IE 6.0 and Opera. I tried in Firefox 1.0 and Mozilla, and these wouldn't display the menu. Just thought I'd point this out.

Fireangel
12-09-2004, 05:23 PM
Thank you so much! Really works fine now!
No problem about the other browsers, dont worry!

My best Regards mate ! :D
Cheers!! :thumbsup:

John



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum