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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mystery. Javascript and css working on one page and not on another. 1

Status
Not open for further replies.

GladysPym

Technical User
Jan 6, 2003
76
GB

OK. The story so far.
I'm trying some fancy moves for hiding and revealing a scrolling div, using DW CS5.

It works on The scroller is under a couple of other divs, and it all works OK. (This is just a test - the page won't look like that in the end).

BUT

I embed identical code into and the scroller stops working.
I'm half guessing it's because I have other javascript in the page, but - well - that's not helping me.

Any thoughts?
 
Hi

GladysPym said:
I'm half guessing it's because I have other javascript in the page
Correct. The following line's effect
Code:
window[teal].[/teal]onload [teal]=[/teal] addScrollers[teal];[/teal]
is simply overwritten by this :
Code:
[b]<body[/b] [maroon]onload[/maroon][teal]=[/teal][green][i]"MM_preloadImages('images/SGcast.png')"[/i][/green][b]>[/b]
GladysPym said:
but - well - that's not helping me.
But why is not helping you ? As you know the problem and the source of problem, you can avoid it or work it around. Some ways :
[ul]
[li]Modify the toggle() function so on first call it also calls addScrollers().[/li]
[li]Call addScrollers() at the end of [tt]body[/tt] without using an event handler.[/li]
[li]Set up the event handler using [tt]addEventListener()[/tt] and [tt]attachEvent()[/tt].[/li]
[/ul]


Feherke.
 
Well, tbh, the reason is I only dabble in js, and am not as up on it as I should be.


Thanks for the full answer.
I'm guessing "Call addScrollers() at the end of body without using an event handler." would be simplest.

I had addscrollers in the front.js file, as well, from an earlier experiment.

I THINK I've done what you suggested, but still no go.
If you're still out there, please reply as though to a virtual newb.

Thanks
 
Hi

GladysPym said:
I THINK I've done what you suggested, but still no go.
Put it at the end of [tt]body[/tt] immediately before the closing [tt]body[/tt] tag. And the most important : enclose the JavaScript code in [tt]script[/tt] tags :
Code:
[gray]<!-- ... the other stuff ... -->[/gray]
[b]</div>[/b]
[highlight][b]<script[/b] [maroon]type[/maroon][teal]=[/teal][green][i]"text/javascript"[/i][/green][b]>[/b][/highlight]
[COLOR=darkgoldenrod]addScrollers[/color][teal]()[/teal]
[highlight][b]</script>[/b][/highlight]
[b]</body>[/b]
[b]</html>[/b]


Feherke.
 
OK. For all you js aficianados, this is probably self-explanatory.
But for ME, it's been helpful, timely, and EXACTLT what I needed.

Thanks, Feherke

Starred, even though it's probably easy for all you experts.
I thank Feherke, and star this post!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top