Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

external & internal multiple scripts

Status
Not open for further replies.

campbellt

Technical User
Mar 22, 2002
3
GB
Thankyou for all those that read this & even better if you have the time to help. BTW It is not obvious that this is a onload problem.

I am running a page that has two conflicting scripts.
1) Menu system that sources from two .js files.
examplmenu_var.js which is the menu config part
& menu_com.js which executes the varibles in above.

2) slideshow that has all code in the html page.

Whilst individually they both work ok but together the menu system does not appear (the slideshow still works ok).

The first part of the body statement relates to the menu system and is the only code for this in the html page:

<script type='text/javascript'>


function Go(){return}
</script>
<script type='text/javascript' src='exmplmenu_var.js'></script>
<script type='text/javascript' src='menu_com.js'></script>
<noscript>Your browser does not support script</noscript>

The slide show code:

<script language=&quot;JavaScript1.2&quot;>

//Fade-in image slideshow- By Dynamic Drive
//For full source code and more DHTML scripts, visit //This credit MUST stay intact for use

var slideshow_width=100 //SET IMAGE WIDTH
var slideshow_height=100 //SET IMAGE HEIGHT
var pause=3000 //SET PAUSE BETWEEN SLIDE (3000=3 seconds)

var fadeimages=new Array()
//SET IMAGE PATHS. Extend or contract array as needed
fadeimages[0]=&quot;photo1.jpg&quot;
fadeimages[1]=&quot;photo2.jpg&quot;
fadeimages[2]=&quot;photo3.jpg&quot;

////NO need to edit beyond here/////////////

var preloadedimages=new Array()
for (p=0;p<fadeimages.length;p++){
preloadedimages[p]=new Image()
preloadedimages[p].src=fadeimages[p]
}

var ie4=document.all&&navigator.userAgent.indexOf(&quot;Opera&quot;)==-1
var dom=document.getElementById&&navigator.userAgent.indexOf(&quot;Opera&quot;)==-1

if (ie4||dom)
document.write('<div style=&quot;position:relative;width:'+slideshow_width+';height:'+slideshow_height+';overflow:hidden&quot;><div id=&quot;canvas0&quot; style=&quot;position:absolute;width:'+slideshow_width+';height:'+slideshow_height+';top:0;filter:alpha(opacity=10);-moz-opacity:10&quot;></div><div id=&quot;canvas1&quot; style=&quot;position:absolute;width:'+slideshow_width+';height:'+slideshow_height+';top:0;filter:alpha(opacity=10);-moz-opacity:10&quot;></div></div>')
else
document.write('<img name=&quot;defaultslide&quot; src=&quot;'+fadeimages[0]+'&quot;>')

var curpos=10
var degree=10
var curcanvas=&quot;canvas0&quot;
var curimageindex=0
var nextimageindex=1


function fadepic(){
if (curpos<100){
curpos+=10
if (tempobj.filters)
tempobj.filters.alpha.opacity=curpos
else if (tempobj.style.MozOpacity)
tempobj.style.MozOpacity=curpos/100
}
else{
clearInterval(dropslide)
nextcanvas=(curcanvas==&quot;canvas0&quot;)? &quot;canvas0&quot; : &quot;canvas1&quot;
tempobj=ie4? eval(&quot;document.all.&quot;+nextcanvas) : document.getElementById(nextcanvas)
tempobj.innerHTML='<img src=&quot;'+fadeimages[nextimageindex]+'&quot;>'
nextimageindex=(nextimageindex<fadeimages.length-1)? nextimageindex+1 : 0
setTimeout(&quot;rotateimage()&quot;,pause)
}
}

function rotateimage(){
if (ie4||dom){
resetit(curcanvas)
var crossobj=tempobj=ie4? eval(&quot;document.all.&quot;+curcanvas) : document.getElementById(curcanvas)
crossobj.style.zIndex++
var temp='setInterval(&quot;fadepic()&quot;,50)'
dropslide=eval(temp)
curcanvas=(curcanvas==&quot;canvas0&quot;)? &quot;canvas1&quot; : &quot;canvas0&quot;
}
else
document.images.defaultslide.src=fadeimages[curimageindex]
curimageindex=(curimageindex<fadeimages.length-1)? curimageindex+1 : 0
}

function resetit(what){
curpos=10
var crossobj=ie4? eval(&quot;document.all.&quot;+what) : document.getElementById(what)
if (crossobj.filters)
crossobj.filters.alpha.opacity=curpos
else if (crossobj.style.MozOpacity)
crossobj.style.MozOpacity=curpos/100
}

function startit(){
var crossobj=ie4? eval(&quot;document.all.&quot;+curcanvas) : document.getElementById(curcanvas)
crossobj.innerHTML='<img src=&quot;'+fadeimages[curimageindex]+'&quot;>'
rotateimage()
}

if (ie4||dom)
window.onload=startit
else
setInterval(&quot;rotateimage()&quot;,pause)

</script>

When running debug in browser it comes up with errors on the html page &quot;functionGo(){return}&quot; expression expected (part of menu script).

And also reports expression expected in both the examplmenu_var.js &quot;function Beforestart () (return)&quot; &
menu_com.js &quot;function Dummy() (return)&quot;

The link for the menu system homepage
Any pointers greatly appreciated.
Thanks
 
put the external calls to the scripts before calling the function, so

<script type='text/javascript' src='exmplmenu_var.js'></script>
<script type='text/javascript' src='menu_com.js'></script>
<noscript>Your browser does not support script</noscript>
<script type='text/javascript'>
function Go(){return}
</script>

also check thru to make sure you do not have conflicting variable names and or other names used. A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
Thanks. Have altered the calls to before the function and renamed all the variables in the slideshow (by prefixing with 'zz')

The slideshow still works, so no typo's created. But still have not got the menu back :(

Any other ideas ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top