|
 |
|
 |
08-20-2006, 07:12 AM
|
#1 (permalink)
|
|
Salchester
Join Date: Jul 2005
Location: In a house
Posts: 230
|
Load Images from a folder
Hello Every,
Is there anybody who could point me in the right direction to load images dynamically from a folder, and display on the screen.
Many Thanks,
__________________
Many Thanks, in advance!
Salchester.
The Future Is Here - Are You Ready?
|
|
|
08-20-2006, 07:15 AM
|
#2 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,470
|
do you have a server-side language available to you? if your server supports PHP, check out readdir.
you can not do this with client side languages (html/javascript) alone.
__________________
Mike
|
|
|
08-20-2006, 07:26 AM
|
#3 (permalink)
|
|
Salchester
Join Date: Jul 2005
Location: In a house
Posts: 230
|
Load Images from a folder
sde,
It is possable in Javascript, as i have acheived it, only an error message displays at execution. This reads as follows:
- Stack overflow at line: 0
Can you/anybody tell me why this is? See code below.
I would prefer to do it in Javascript rathewr than PHP as it will only be used on my machine not uploaded to a server.
Code:
<script type="text/javascript">
function play(media) {
var promptStr = 'Playing:'+media.substring(media.lastIndexOf('/')+1)+'<br>';
var objectStr = '<object classid="clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95"'+'type="application/x-oleobject" width="412" height="276">'+
'<param name="showControls" value="false">'+
'<param name="fileName" value="'+media+'">'+
'<embed type="application/x-mplayer2" width="320" height="285"'+'showcontrols="true" src="'+media+'"><\/embed>'+
'<\/object>'
document.getElementById('mediaplayer').innerHTML=promptStr+objectStr;
}
var myImages = new Array();
var i=1;
var dir = "images/"
function loadNext(thePic) {
var theSrc=thePic.src;
var w=thePic.width;
var h=thePic.height;
if (w<h) { // portrait
w=54;
h=74;
}
else { // landscape
w=74;
h=54;
}
myImages[myImages.length]='<img src="'+theSrc+'" width="'+w+'" height="'+h+'" border="0">';
document.loadImage.src=dir+(i++)+'.gif'
}
function show() {
window.status='Done'
var text = '';
text +='<table border="0">'
for (var i=0;i<myImages.length;) {
text += '<tr>'
for (var j=0;j<3 && i<myImages.length;j++) {
text +='<td><a href="'+dir+i+'.wmv" onClick="play(\''+dir+i+'.wmv\'); return false">'+
myImages[i]+'</a></td>';
i++;
}
text += '</tr>'
}
document.getElementById('allLinks').innerHTML=text;
}
</script>
<div id="allLinks"></div>
<div id="allImages" style="display:none">
<img
src="images/0.gif" name="loadImage" width="150" height="108" onError="show()" onLoad="loadNext(this)">
</div>
<ul id="menu">
<li><a onclick="play('box1.wmv');return false" href="">Source 1</a></li>
<li><a onclick="play('1.mpg');return false" href="">Source 2</a></li>
<li><a onclick="play(this.href);return false" href="">Source 3</a></li>
</ul>
<div id="mediaplayer"></div>
Many Thanks,
__________________
Many Thanks, in advance!
Salchester.
The Future Is Here - Are You Ready?
|
|
|
08-20-2006, 08:28 AM
|
#4 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,470
|
it is not possible. (reading a server directory with javascript without the combined use of server-side languages)
maybe that java applet you are embedding is doing something different, but java is not javascript. if you are using a java applet to do the directory browsing somehow, you need to refer to the documentation from the author.
__________________
Mike
|
|
|
08-20-2006, 09:04 AM
|
#5 (permalink)
|
|
Newbie
Join Date: Jun 2002
Location: Denmark
Posts: 1,695
|
Well your version isn't dynamicaly loading what ever pic is found in the directory.. It assumes theres alot of images all called 1.gif, 2.gif, 3.gif ..., N.gif
Yet the N isn't specified, so if you have 5 images, and you keep on pressing <next> it will eventualy display "Image not found", not stop when the end of your available images is reached.
As to your error, I havn't looked too much on the code, so at this point I have no solution for you.
|
|
|
08-22-2006, 02:03 AM
|
#6 (permalink)
|
|
Salchester
Join Date: Jul 2005
Location: In a house
Posts: 230
|
Load images from a folder
Redhead & sde,
Is there anyway of recoding this in order for it to successfullly work in IE with no wanring messages.
Also for some odd reason the images dont display straight away at load up, why is this? Can this also be resolved?
Many Thanks,
__________________
Many Thanks, in advance!
Salchester.
The Future Is Here - Are You Ready?
|
|
|
08-22-2006, 06:06 AM
|
#7 (permalink)
|
|
Moderator
Join Date: May 2002
Location: us.ca
Posts: 4,470
|
i can see that a lot of lines in your code do not end with a semi-colon. here are just a few. you may want to go through and clean that up, maybe it will help.
HTML Code:
var dir = "images/"
HTML Code:
window.status='Done'
var text = ''; // this one is ok
text +='<table border="0">'
__________________
Mike
|
|
|
08-22-2006, 06:10 AM
|
#8 (permalink)
|
|
Salchester
Join Date: Jul 2005
Location: In a house
Posts: 230
|
sde,
Where do i put them? Can you help?
__________________
Many Thanks, in advance!
Salchester.
The Future Is Here - Are You Ready?
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -8. The time now is 08:04 PM.
|
Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
|
 |
|