• 0

Use list.txt with JavaScript?


Question

I have a file called "list.txt" that has a directory listed off all the images in that directory.

How can I use this file in a javascript to show a picture from the list at random?

I have this list of images so I can have the script choose one of the images at random to be displayed on the web page reload.

---

I'm trying to do a script like LongHorn Bar and trying to figure ways to do this via my other posts here on Neowin and this seems like a sure fire way I hope only if I can get it to work.

Here is what I'm trying to do:

https://www.neowin.net/forum/index.php?act=...ST&f=34&t=70241

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Call it list.js, have each picture set as a variable, then just call the variables?

I think using vbscript would give you more options.

Edited by yashiro
Link to comment
Share on other sites

  • 0

Thanks yashiro,

Do you know how I can put this into the code I have now? I want to be able to have like 50 or more images in the list.

<html>

<HEAD>

<TITLE>Picture Toolbar</TITLE>

<META HTTP-EQUIV="Refresh" CONTENT="30">

<META http-equiv="Page-Enter" content="revealTrans(Duration=4,Transition=23)">

<META http-equiv="Page-Exit" content="revealTrans(Duration=4,Transition=23)">

<script language="JavaScript">

<!-- Hide this script from old browsers --

var random = Math.random() ;

var picnum = Math.round(random*17)+1;

// -- End Hiding Here -->

</script>

</head>

<BODY leftMargin=0 topMargin=0 bgcolor="threedface" scroll=no>

<script language="JavaScript">

<!-- Hide this script from old browsers --

document.write('<img src=pics/pic'+picnum+'.jpg border="0" size=100% width=100%>')

// -- End Hiding Here -->

</script>

</body>

</html>

Is there any way to use a directory full of images instead of having to list the filenames? So I can just choose a directory full of images instead?

Link to comment
Share on other sites

  • 0

I don't think javascript is upto the task. (not the way you want it to work)

Javascript is fairly restrictive; I think vbscript could do it but perhaps, like myself, you have little exp using vbscript.

Link to comment
Share on other sites

  • 0

I don't know vbscript at all, but want to learn. Is there anyway to you edit my script so it can use the list.js since I don't know how yet? Thanks for the help so far. :)

I do this for the list:::: dir /b > list.txt and rename it to *.js

So now it has a list of the images (which might be around 50 or so sometimes) and I want it to be able to pick an file from the list and display it. I don't care about a link really since there is no reason to really click on the picture.

Here is what I'm trying to from this post:

https://www.neowin.net/forum/index.php?act=...=34&t=70241&hl=

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.