Technology Career. Leadership. Life.

The Intersection – where technology career, leadership and life intersect.

Menu
  • Home
  • About
  • Learn with me
  • Speaking
  • Resources
  • Subscribe
  • Contact
Menu

Display a flash/image/text file randomly using javascript

Posted on May 18, 2008May 18, 2008 by eisabai

The following javascript snippet will get the name of a random file from a list of files specified.

<script type="text/javascript">
//name of files
filenames = [ "filename1.gif", "filename2.gif", "filename3.gif", "filename4.gif" ];

//get a random entry from an array of filenames
var filename = filenames[Math.floor(Math.random()*filenames.length)];

//display filename here
document.write("path/to/file" + filename);
</script>

[tags]javascript, snippet[/tags]

4 thoughts on “Display a flash/image/text file randomly using javascript”

  1. Jeevan says:
    November 24, 2008 at 8:00 pm

    i checked it and it’s working fine
    thanks a lot

  2. test says:
    April 17, 2009 at 9:21 pm

    test

  3. IP Counter says:
    March 15, 2011 at 2:53 am

    Hab ihn gelesen und finde Ihn sehr hilfreich Danke nochmal :-)

    http://www.ipcounter.net/

  4. enuotiz says:
    April 8, 2011 at 2:06 am

    it’s not working for text file

Comments are closed.

About

Hello! Welcome to my blog! My name is Ei Sabai (pronounced Isabel) and on this blog, I write about technology, career, entrepreneurship and life. I started this blog in 2005 and for a decade, the main focus of this blog was web development. I rebranded my blog in 2016 to accommodate bigger and better things (although I will always be a technologist at heart)!

Want to chat with me for an opportunity, an idea or a speaking engagement? You can find me on LinkedIn or Twitter.

Learn

Get Unstuck in Your Coding Career
7 strategies to grow your career
Thought Leadership

Web Development Resources

  • WordPress Web Hosting
  • iPhone Native App Development
  • iPhone Web App Development
  • Coupons for Web Developers
  • 10 Useful jQuery Snippets
  • How to Code HTML Email Newsletters
More Tips & Resources
© 2019 Technology Career. Leadership. Life. | Theme by Superb Themes