Forum Moderators: open

Message Too Old, No Replies

Multiple Java Scripts.

menu and slide show menu doesn't work

         

ttpgirl

10:19 pm on Jun 27, 2006 (gmt 0)

10+ Year Member



I know this may be a newbie question, but I've searched the entire forum and can't seem to find anything on how to fix it. I have a javascript image slider and a javascript menu. The menu will not work once I've inserted the slideshow script. What can I do to make both work properly. Thanks in advance for any help. Here are my scripts:

Slide Show:
<script type="text/javascript">

var sliderwidth="800px"
var sliderheight="146px"
//Specify the slider's slide speed (larger is faster 1-10)
var slidespeed=2
//configure background color:
slidebgcolor="#31387B"

//Specify the slider's images
var leftrightslide=new Array()
var finalslide=''
leftrightslide[0]='<img src="1.jpg" border=0>'
leftrightslide[1]='<img src="2.jpg" border=0>'
leftrightslide[2]='<img src="3.jpg" border=0>'
leftrightslide[3]='<img src="4.jpg" border=0>'
leftrightslide[4]='<img src="5.jpg" border=0>'
leftrightslide[5]='<img src="6.jpg" border=0>'
leftrightslide[6]='<img src="7.jpg" border=0>'
leftrightslide[7]='<img src="8.jpg" border=0>'
leftrightslide[8]='<img src="9.jpg" border=0>'

//Specify gap between each image (use HTML):
var imagegap=""

//Specify pixels gap between each slideshow rotation (use integer):
var slideshowgap=0

////NO NEED TO EDIT BELOW THIS LINE////////////

var copyspeed=slidespeed
leftrightslide='<nobr>'+leftrightslide.join(imagegap)+'</nobr>'
var iedom=document.all¦¦document.getElementById
if (iedom)
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100px;left:-9000px">'+leftrightslide+'</span>')
var actualwidth=''
var cross_slide, ns_slide

function fillup(){
if (iedom){
cross_slide=document.getElementById? document.getElementById("test2") : document.all.test2
cross_slide2=document.getElementById? document.getElementById("test3") : document.all.test3
cross_slide.innerHTML=cross_slide2.innerHTML=leftrightslide
actualwidth=document.all? cross_slide.offsetWidth : document.getElementById("temp").offsetWidth
cross_slide2.style.left=actualwidth+slideshowgap+"px"
}
else if (document.layers){
ns_slide=document.ns_slidemenu.document.ns_slidemenu2
ns_slide2=document.ns_slidemenu.document.ns_slidemenu3
ns_slide.document.write(leftrightslide)
ns_slide.document.close()
actualwidth=ns_slide.document.width
ns_slide2.left=actualwidth+slideshowgap
ns_slide2.document.write(leftrightslide)
ns_slide2.document.close()
}
lefttime=setInterval("slideleft()",30)
}
window.onload=fillup

function slideleft(){
if (iedom){
if (parseInt(cross_slide.style.left)>(actualwidth*(-1)+8))
cross_slide.style.left=parseInt(cross_slide.style.left)-copyspeed+"px"
else
cross_slide.style.left=parseInt(cross_slide2.style.left)+actualwidth+slideshowgap+"px"

if (parseInt(cross_slide2.style.left)>(actualwidth*(-1)+8))
cross_slide2.style.left=parseInt(cross_slide2.style.left)-copyspeed+"px"
else
cross_slide2.style.left=parseInt(cross_slide.style.left)+actualwidth+slideshowgap+"px"

}
else if (document.layers){
if (ns_slide.left>(actualwidth*(-1)+8))
ns_slide.left-=copyspeed
else
ns_slide.left=ns_slide2.left+actualwidth+slideshowgap

if (ns_slide2.left>(actualwidth*(-1)+8))
ns_slide2.left-=copyspeed
else
ns_slide2.left=ns_slide.left+actualwidth+slideshowgap
}
}

if (iedom¦¦document.layers){
with (document){
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
if (iedom){
write('<div style="position:relative;width:'+sliderwidth+';height:'+sliderheight+';overflow:hidden">')
write('<div style="position:absolute;width:'+sliderwidth+';height:'+sliderheight+';background-color:'+slidebgcolor+'" onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed">')
write('<div id="test2" style="position:absolute;left:0px;top:0px"></div>')
write('<div id="test3" style="position:absolute;left:-1000px;top:0px"></div>')
write('</div></div>')
}
else if (document.layers){
write('<ilayer width='+sliderwidth+' height='+sliderheight+' name="ns_slidemenu" bgColor='+slidebgcolor+'>')
write('<layer name="ns_slidemenu2" left=0 top=0 onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed"></layer>')
write('<layer name="ns_slidemenu3" left=0 top=0 onMouseover="copyspeed=0" onMouseout="copyspeed=slidespeed"></layer>')
write('</ilayer>')
}
document.write('</td></table>')
}
}
</script>

Menu:
<SCRIPT type=text/javascript>
function Go(){return}
</SCRIPT>

<SCRIPT src="http://www.mysite.com/exmplmenu_var.js" type=text/javascript></SCRIPT>

<SCRIPT src="http://www.mysite.com/menu_com.js" type=text/javascript></SCRIPT>
<noscript>Your browser does not support script</noscript>

texmex

10:53 pm on Jun 27, 2006 (gmt 0)

10+ Year Member



Doubt anyone here will be able to help, due to lack of information.

Doing a quick copy and past of the script you have given, I found that I needed to replace the pipe symbols (¦) with these ones (¦) to get it working.

To put these into context, in your script they appear in two lines.
var iedom=document.all¦¦document.getElementById
and
if (iedom¦¦document.layers)

This is more likely to be an artefact of the transition from your HTML document to this forum post than a bug in your source code. Could be worth checking though.

Having got this sorted, your slide show works on my machine (albeit without any pictures as I don't have them here:-) )

Obviously the menus still don't as I don't have the source code for your menus. Hence, I haven't a snowball in hells chance of getting any further.

What I'd suggest is that you use Firefox with the console2 extention. Open your page, go into the javascript console to see what errors are being reported.

You only need one syntax durning the loading phase to totally stop all further javascript dead in it's tracks.

texmex

10:55 pm on Jun 27, 2006 (gmt 0)

10+ Year Member



Told you that pipe symbol was an artefact of the forum didn't I? I notice the ones I've suggested now look identical to the ones I had to replace :-)

ttpgirl

11:12 pm on Jun 27, 2006 (gmt 0)

10+ Year Member



the script to the menu is here

<SCRIPT src="http://www.shadowtrailers.com/exmplmenu_var.js" type=text/javascript></SCRIPT>

<SCRIPT src="http://www.shadowtrailers.com/menu_com.js" type=text/javascript></SCRIPT>

I hope this helps, I still haven't been able to fix it. :(

texmex

1:56 am on Jun 28, 2006 (gmt 0)

10+ Year Member



I've just added the two lines Exactly as you gave them in your last post, and the file I now have works fine. Slideshow is running across the top, and now I have the dropdown menues. It may need a little work on the presentation as the slideshow is slightly obscured by the menues. Depends on your images (which I haven't got so don't know wha t the finished effect will be).

I wonder if your problem is where you are placing the script in your document.

The document I have just created consists of:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

Followed by:
All of your script exactly as it appears in your first post (including the two script tags you provided in your second post)

Followed by:


<title></title>
</head>
<body>
</body>
</html>

From this you can see that I've put ALL of the script within the HEAD of the document. Are you perhaps including it somewhere in the body instead?

ttpgirl

2:19 am on Jun 28, 2006 (gmt 0)

10+ Year Member



yes, I am including it in the body. I thought I had to put the script to the slideshow exactly where I want it to be positioned in the body? Am I wrong? By the way, thank yiou so much for taking your time with me! :)

texmex

2:32 am on Jun 28, 2006 (gmt 0)

10+ Year Member



I haven't really studied the scripts that closely. The Head is the place that scripts belong, but even a from a casual glance I've noticed that you have some "document.write" commands in your slideshow script. These tend to be fairly dependant on where they are placed to cause them to appear in the correct position on your page. So at first glance, your interprettation seems to be correct.

Before I made my last post, I did experiment with the script in the body and found it didn't work like that. I'll have a deeper poke, to see if I can work out what's at the root of the problem.

ttpgirl

2:32 am on Jun 28, 2006 (gmt 0)

10+ Year Member



I tried putting it all in my head tag, and it doesn't work. You put all of it in your head tag yousaid? I wonder why mine won't work..hmm

ttpgirl

2:36 am on Jun 28, 2006 (gmt 0)

10+ Year Member



Thank you very much! I appreciate it so much.

texmex

3:35 am on Jun 28, 2006 (gmt 0)

10+ Year Member



Right I think I can help.

Your tags to your external scripts (those two that you gave in your second post) want to be in the head.

Next: In your first post you have a section that looks like


Menu:
<SCRIPT type=text/javascript>
function Go(){return}
</SCRIPT>

Remove this in it's entirety. It's overriding a function that is in your menu_com.js file.

Place all of the script for your slide show in the document body, where you want the slide show to be. (just as you suggested)

Now the Go function of your menu_com.js file needs to be called, but you can call this from your fillup function.

So where you have


function fillup(){
if (iedom){
etc...

You want


function fillup(){
Go()
if (iedom){
etc...

By the way, it is case sensitive so make it an uppercase G followed by a Lower case o(and then open and close brackets).

ttpgirl

3:50 am on Jun 28, 2006 (gmt 0)

10+ Year Member



WOW! YOU ROCK! It works...thank you thank you thank you! This is greatly appreciated! You don't know how much you've helped!

texmex

4:21 am on Jun 28, 2006 (gmt 0)

10+ Year Member



Why thanks, I've never been accused of rocking before. Makes me feel kinda young again :-)