473,385 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to link an external Div scroller script..

leet
4
I have used a piece of javascript code to scroll the main content of my website, this works well but I want to externally import from a javascript file format.I have tried many ways for the solution of this problem but have not managed to solve it . below is the javascript source code and the HTML that I will be using it in.

JavaScript code:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3. scrollStep=3
  4.  
  5. timerUp=""
  6. timerDown=""
  7.  
  8. function toTop(id){
  9. document.getElementById(id).scrollTop=0
  10. }
  11.  
  12. function scrollDivDown(id){
  13. clearTimeout(timerDown) 
  14. document.getElementById(id).scrollTop+=scrollStep
  15. timerDown=setTimeout("scrollDivDown('"+id+"')",5)
  16. }
  17.  
  18. function scrollDivUp(id){
  19. clearTimeout(timerUp)
  20. document.getElementById(id).scrollTop-=scrollStep
  21. timerUp=setTimeout("scrollDivUp('"+id+"')",10)
  22. }
  23.  
  24. function toBottom(id){
  25. document.getElementById(id).scrollTop=document.getElementById(id).scrollHeight
  26. }
  27.  
  28. function stopMe(){
  29. clearTimeout(timerDown) 
  30. clearTimeout(timerUp)
  31. }
  32.  
  33. </script>


HTML
========
Expand|Select|Wrap|Line Numbers
  1. <div id="scroll">
  2. <a onclick="toTop('container')"> Top </a> 
  3. <a onmouseover="javascript:scrollDivDown('container');" onmouseout="stopMe();"> Scroll Down </a> 
  4. <a onmouseover="scrollDivUp('container')" onmouseout="stopMe()"> Scroll Up </a>
  5. <a onclick="toBottom('container')"> Bottom </a>
  6. </div>
  7.  
(container is the div that is to be scrolled)


I would appreciate your help very much on how to link this code externally..

Thanks :)

- L33T(leet)
Apr 8 '10 #1
3 3839
Dormilich
8,658 Expert Mod 8TB
you mean something like
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" src="file.js"></script>
?
Apr 8 '10 #2
leet
4
Oddly enough I have tried that.. but it still does not work :(.. I am pretty suck for ideas..

EDIT
=====

I've opened up the js file in Dreamweaver CS4.. and it states that there is a syntax error in line 14..

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3. scrollStep=3
  4.  
  5. timerUp=""
  6. timerDown=""
  7.  
  8. function toTop(id){
  9. document.getElementById(id).scrollTop=0
  10. }
  11.  
  12. function scrollDivDown(id){
  13. clearTimeout(timerDown) 
  14. document.getElementById(id).scrollTop+=scrollStep
  15. timerDown=setTimeout("scrollDivDown('"+id+"')",5)
  16. }
  17.  
  18. function scrollDivUp(id){
  19. clearTimeout(timerUp)
  20. document.getElementById(id).scrollTop-=scrollStep
  21. timerUp=setTimeout("scrollDivUp('"+id+"')",10)
  22. }
  23.  
  24. function toBottom(id){
  25. document.getElementById(id).scrollTop=document.getElementById(id).scrollHeight
  26. }
  27.  
  28. function stopMe(){
  29. clearTimeout(timerDown) 
  30. clearTimeout(timerUp)
  31. }
  32.  
  33. </script>
  34.  
Any reason why this is ?
Apr 9 '10 #3
Dormilich
8,658 Expert Mod 8TB
first I’d try setting the semi-colons (command limiter). then I’d try
Expand|Select|Wrap|Line Numbers
  1. timerUp = setTimeout(scrollDivUp, 10, id);
Apr 11 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Jamie Jackson | last post by:
I know that it's possible to return false in an onClick to disable a link. Is there a way to do this within the HREF attribute? Something like: <a href="javascript: return false;"> ? Thanks,...
3
by: Razvan | last post by:
Hello, Can somebody recommend me a Java Script scroller that can scroll an i-frame ? I tried the Tigra scroller (www.softcomplex.com/products/tigra_scroller/) but sometimes it does not...
5
by: mistral | last post by:
Simple status bar scroller: </head> <SCRIPT LANGUAGE="JavaScript"> <!-- This script and many more are available free online at --> <!-- The JavaScript Source!! http://javascript.internet.com...
14
by: mistral | last post by:
Below is Typewriter Scroller script. I want adjust is as follows: remove lower dash "_" out; display text not in form, but inside div, without any borders (style="visibility:hidden"). Also I need...
14
by: Mars | last post by:
I'm looking for a javascipt vertical news scroller that will scroll from the bottom of the page to the top showing many new items. Would really appreciate some help. The scroller I'm using at...
6
by: info | last post by:
hello all, if anyone out there could help me i would really appreciate it. i am very much a novice coder. I have a site we are building and we have created a section in the admin area to allow the...
9
by: John | last post by:
I need a scroller (java) or whatever that can read a php file and display it in the script. Does anyone know of any? I have searched the script sites but didn't find anything.
1
by: mirroras | last post by:
Hi all !! I have a difficult issue. I use the Manual Scroller script from dynamicDrive. This script is full working and is cross-browser. The url is for it, is...
3
by: Michellevt | last post by:
Hi I am working on a project (for college) and wondered if anyone can help me with my problem. In the project we are not allowed to make use of any "style" attributes but "class" attributes...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.