/    Sign up×
Community /Pin to ProfileBookmark

Help Problem with JS in Safari

I found a java script that allow for a new image to load on refresh from a series of images. It works fine in IE and Firefox, however in Safari when I hit refresh the page goes blank. The image is the first thing to load on the page. Also, if I do not delete this line of code: <script language=”JavaScript”>, then I get an error in Dreamweaver. I will warn you that I don’t know much about this stuff. Any suggestions would be appreciated.

[url]http://studentaccess.emporia.edu/~jdecker/website1/index.html[/url]

Here is the script:

<!– TWO STEPS TO INSTALL RANDOM IMAGE SCRIPT:

  • 1. Copy the coding into the HEAD of your HTML document

  • 2. Add the last code into the BODY of your HTML document –>
  • <!– STEP ONE: Paste this code into the HEAD of your HTML document –>

    <HEAD>

    <!– This script and many more are available free online at –>
    <!– The JavaScript Source!! [url]http://javascript.internet.com[/url] –>
    <!– Original: jsCode.com –>
    <!– Web Site: [url]http://jscode.com[/url] –>
    <script language=”JavaScript”>
    <!–
    // ==============================================
    // Copyright 2003 by jsCode.com
    // Source: jsCode.com
    // Author: etLux
    // Free for all; but please leave in the header.
    // ==============================================

    // Set up the image files to be used.
    var theImages = new Array() // do not change this
    // To add more image files, continue with the
    // pattern below, adding to the array. Rememeber
    // to increment the theImages[x] index!

    theImages[0] = ‘100.jpg’
    theImages[1] = ‘200.jpg’
    theImages[2] = ‘300.jpg’
    theImages[3] = ‘400.jpg’
    theImages[4] = ‘500.jpg’

    // ======================================
    // do not change anything below this line
    // ======================================

    var j = 0
    var p = theImages.length;

    var preBuffer = new Array()
    for (i = 0; i < p; i++){
    preBuffer[i] = new Image()
    preBuffer[i].src = theImages[i]
    }

    var whichImage = Math.round(Math.random()*(p-1));
    function showImage(){
    document.write(‘<img src=”‘+theImages[whichImage]+'”>’);
    }

    //–>
    </script>
    </HEAD>

    <!– STEP TWO: Copy this code into the BODY of your HTML document –>

    <BODY>

    <!– This script and many more are available free online at –>
    <!– The JavaScript Source!! [url]http://javascript.internet.com[/url] –>
    <!– Original: jsCode.com –>
    <!– Web Site: [url]http://jscode.com[/url] –>
    <script language=”JavaScript”>
    <!–
    showImage();
    //–>
    </script>

    <p><center>
    <font face=”arial, helvetica” size”-2″>Free JavaScripts provided<br>
    by <a href=”http://javascriptsource.com”>The JavaScript Source</a></font>
    </center><p>

    <!– Script Size: 2.02 KB –>

    to post a comment
    JavaScript

    1 Comments(s)

    Copy linkTweet thisAlerts:
    @FangApr 14.2009 — Use [COLOR="Blue"]<script type="text/javascript">[/COLOR] for script

    and [COLOR="Blue"]<style type="text/css">[/COLOR] for style
    ×

    Success!

    Help @nutmegsoccerusa spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.4,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,

    tipper: @Samric24,
    tipped: article
    amount: 1000 SATS,
    )...