473,396 Members | 1,827 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,396 software developers and data experts.

multiple java scripts on one page?

I'm very new to java- as a matter of fact, I'd say that I know nothing about it....except for how to cut and paste free java script to my pages.

I have the need for three different slide shows on my index page. Two of them are working- and the third one won't show up at all. I tried to do it as an "includes" page- nothing worked, only an error message.

I finally have all three scripts showing the pictures but one of them was not designed to have clickable links- and I don't know how to rewrite it.

So my question is: Is there a limit to how many scripts you can have on a page? What causes them to conflict? Is there a way to do them as includes?

any advice would be appreciated. I want to learn but don't know where to start.

Here's the script that I'd like to be able to make as links:
<td>&nbsp;<script language="javascript">

/*
Random image slideshow- By Tyler Clarke (tyler@ihatecoffee.com)
For this script and more, visit http://www.javascriptkit.com
*/

var delay=5000 //set delay in miliseconds
var curindex=0

var randomimages=new Array()

randomimages[0]="/banners/urbanabannersm.jpg"
randomimages[1]="/banners/diamondwbanner2.jpg"
randomimages[2]="/banners/classicbanner.jpg"
randomimages[3]="/banners/oxygenbanner.jpg"


var preload=new Array()

for (n=0;n<randomimages.length;n++)
{
preload[n]=new Image()
preload[n].src=randomimages[n]
}

document.write('<img name="defaultimage" src="'+randomimages[Math.floor(Math.random()*(randomimages.length))]+'">')

function rotateimage()
{

if (curindex==(tempindex=Math.floor(Math.random()*(ra ndomimages.length)))){
curindex=curindex==0? 1 : curindex-1
}
else
curindex=tempindex

document.images.defaultimage.src=randomimages[curindex]
}

setInterval("rotateimage()",delay)

</script>
May 3 '06 #1
1 5347
Enyi
38
So my question is: Is there a limit to how many scripts you can have on a page? What causes them to conflict? Is there a way to do them as includes?

any advice would be appreciated. I want to learn but don't know where to start.
There is no limit to how many scripts you can have on one page. In fact, the page treats all javascript on the page as a single script. So there can be conflicts between scripts if they use the same variable / function names etc. I'm not sure if those type of conflicts would still exist if the javascript was in seperate .js files.

You can use <script language="javascript"></script> as many times as you want.

To make in images clickable links in HTML, you would write:

[HTML]
<a href="file to link to" alt="Some text to display if mouse hovers over image"><img src="path to image to display" border="0"></a>
[/HTML]

So to rewrite your code to make images clickable, look for this line:

[HTML]
document.write('<img name="defaultimage" src="'+randomimages[Math.floor(Math.random()*(randomimages.length))]+'">')
[/HTML]

and change it to something like below:

[HTML]
document.write('<a href="file you want"><img name="defaultimage" border="0" src="'+randomimages[Math.floor(Math.random()*(randomimages.length))]+'"></a>')
[/HTML]

For a bit of reference, you may want to visit:
http://www.webmonkey.com/webmonkey/r..._code_library/
Jul 12 '06 #2

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

Similar topics

3
by: Alexander Fillips | last post by:
Hi, my short question: is there a python object which can interpret java-script? the whole story ;-) I wrote some streaming-scripts for the xbox mediaplayer which supports python. for a...
2
by: RJ | last post by:
We currently send product releases to our customers, and often have to include scripts that need to be ran on the Oracle databases (also do it for SqlServer customers, but we use a different set of...
3
by: imrantbd | last post by:
I need array type name like "destList" must use for my destlist select box,not a single name.Or need a solution to capture multiple value of "destList" select box and send all selected value in php...
1
by: Italian Pete | last post by:
Hi, I have a usercontrol which includes a small piece of Javascript built up as a string in <scripttags and put onto a web page when an instance of the User Control is created. The Javascript does...
5
by: Ankur | last post by:
Hi Folks, I am new for this group. I want to clarify one thing what's a basic difference between Client Side Java Script and Server Side Java Script. how we can differentiate it. Why we called...
1
by: Memphis Steve | last post by:
Is it possible to combine multiple javascipts into one file and then call that file from a linked URL in the head section of an XHTML file? Here are the two scripts I want to use with the...
5
by: Max | last post by:
Is there any way to set a select-multiple type <select multiple="multiple"with multiple selected options in scripting? Any idea about this is appreciative.
1
by: Daniel Kaplan | last post by:
I know I can have multiple scripts on one HTML page (at least I think I know I can). i.e. <script language="Javascript" type="text/javascript" src="../js/mainbutts.js"></script> ...html...
7
by: imtmub | last post by:
I have a page, Head tag Contains many Scripts and style sheet for Menu and Page. This code working fine and displaying menus and page as i wanted. Check this page for reference....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.