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

Changing Images: Question about obtaining image names

08242005 1416 GMT-5

Recently some of you helped me with a script to change images. Well I
was asked to make a change to the script and not knowing if what the
school system is even possible, Ill ask you all.

The script just loads some images and roates through them. However, the
school wants to be able to put more and more pictures in the folder and
the script pull all the images for rotation.

Ok, first I notice that all the images are pulled into an array. The
pictures that I have now are not uniformly named. Also, I do not know
from day to day if one will be added.

Is the a way to run through an unknown number of images with only
specifing the ending, like "run everything .jpg"?

Wade

Aug 24 '05 #1
3 1895
Wade schrieb:
08242005 1416 GMT-5

Recently some of you helped me with a script to change images. Well I
was asked to make a change to the script and not knowing if what the
school system is even possible, Ill ask you all.

The script just loads some images and roates through them. However, the
school wants to be able to put more and more pictures in the folder and
the script pull all the images for rotation.

Ok, first I notice that all the images are pulled into an array. The
pictures that I have now are not uniformly named. Also, I do not know
from day to day if one will be added.

Is the a way to run through an unknown number of images with only
specifing the ending, like "run everything .jpg"?

Wade


Hi Wade,

well, it is possible - but not with client-side JavaScript. The images are
located in a directory on a webserver. The Script is running on a client
computer. The client doesn't know anything about files on the server without you
(or the server itself) telling him what files are lying there around (OK, the
client could try to load every possible string as filename).

So you have to insert the imagefiles to rotate on the site by any serverside
script (PHP, Perl, JSP or something like this) that reads the directorycontent
serverside and generates the filelist for the JS before submitting the page to
the client.

greetings,

Martin
Aug 24 '05 #2
alu

"Martin Kurz" <in**@martinkurz.in-berlin.de> wrote
Wade schrieb:
Is the a way to run through an unknown number of images with only
specifing the ending, like "run everything .jpg"?

Wade


Hi Wade,

well, it is possible - but not with client-side JavaScript. The images are
located in a directory on a webserver. The Script is running on a client
computer. The client doesn't know anything about files on the server

without you (or the server itself) telling him what files are lying there around (OK, the client could try to load every possible string as filename).

So you have to insert the imagefiles to rotate on the site by any serverside script (PHP, Perl, JSP or something like this) that reads the directorycontent serverside and generates the filelist for the JS before submitting the page to the client.

greetings,

Martin

Not exactly true. There is a way to do this client side, although it's a bit
tricky & may not work on some servers or on Safari (untested).
You can load the image directory url (which cannot contain an index.html
file) into an invisible iframe, then onload loop through the iframe's links
and check for ".jpg"
(this will not work with local files or cross-domain)
A quick test....

<iframe src="images/" name="imageDir" id="imageDir"
onload="imagesInIframe();" style="display:none"></iframe>

<sc ript type="text/javascript">

var imageFrame = self.frames['imageDir']

function imagesInIframe() {
for (var i = 0; i < imageFrame.document.links.length; i++) {
alert(imageFrame.document.links[i])
}
}

</sc ript>

Note the iframe onload attribute is only available in IE6 & Mozilla as far
as I know.
For more cross-browser compatibility you could check if the iframe has
loaded every few 100 milliseconds vs. using the onload attribute.
-alu
Aug 25 '05 #3
Not exactly true. There is a way to do this client side, although it's a bit
tricky & may not work on some servers or on Safari (untested).
You can load the image directory url (which cannot contain an index.html
file) into an invisible iframe, then onload loop through the iframe's links
and check for ".jpg"
(this will not work with local files or cross-domain)
A quick test....

<iframe src="images/" name="imageDir" id="imageDir"
onload="imagesInIframe();" style="display:none"></iframe>

<sc ript type="text/javascript">

var imageFrame = self.frames['imageDir']

function imagesInIframe() {
for (var i = 0; i < imageFrame.document.links.length; i++) {
alert(imageFrame.document.links[i])
}
}

</sc ript>

Note the iframe onload attribute is only available in IE6 & Mozilla as far
as I know.
For more cross-browser compatibility you could check if the iframe has
loaded every few 100 milliseconds vs. using the onload attribute.
-alu


Well, as I said: "The client doesn't know anything about files on the server
without you (or the server itself) telling him what files are lying there
around". The list has to be generated serverside, it can't get generated clientside.
Aug 26 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: antishok | last post by:
Hi, I'm writing a page which has a somewhat similar folder tree to that of the windows explorer, where each folder is made of a <SPAN> tag consisting of the folder image (closed or open) and the...
8
by: Chris Beall | last post by:
I'm struggling with how to handle, on a web page, images that contain text that the user must be able to read. Examples: tombstone photos, photos or scans of historic documents (handwritten or...
3
by: Shailaja Kulkarni | last post by:
hi All, This problem is for C# windows application. I have a user control whcih contains one picture box along with other controls. Depending on certain conditions I want to change images on the...
6
by: Nish | last post by:
I want to down load all images kept under particular URL. Here is the example..... www.my1111site.com/images/1234.jpg www.my1111site.com/images/1234.jpg I only know the url upto...
0
by: Steave | last post by:
Hi, using Managed C++ (.Net 2.0), I want to embed some images within an executable using a .resX file, and upon an event (in this case a combo box changing), I want the picture box to update with a...
10
by: eholz1 | last post by:
Hello Members, I am setting up a photo website. I have decided to use PHP and MySQL. I can load jpeg files into the table (medium blob, or even longtext) and get the image(s) to display without...
10
by: Anthony | last post by:
I am using the following code to display fading pictures on a team website. Can someone show me how to modify it such that I can display the names of each employee when the picture changes? This...
0
by: zeckdude | last post by:
Hi, I am having some issues with my site. I have a main Nav with four links that load in 4 different sections. You can see the page I am working on here:...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.