/    Sign up×
Community /Pin to ProfileBookmark

displaying jpg if swf doesn’t display

hi guys

i know there is some javascript code to make this work but i cant seem to find it.i want a jpg to display as default if my swf doesn’t apear. i’m not sure how to go about in doing this but i know there is a way to do it. i ‘ve seen it on various sites like [url]www.starwars.com[/url] if you don’t have flash a default picture apears in the swf’s place. i know you need some javascript to make this work please help!!!!!!

gavin

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@bathurst_guyNov 29.2005 — i use this:
<i>
</i>&lt;script type="text/javascript" src="flash.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
&lt;!-- Description of what this script does is in the file flash.js
if (flashInstalled){
document.write ('&lt;object type="application/x-shockwave-flash" data="images/logo.swf" width="160px" height="90px"&gt;');
document.write ('&lt;param name="movie" value="images/logo.swf" width="160px" height="90px" quality="high" menu="false" /&gt;');
document.write ('&lt;/object&gt;');
}
else {
document.write ('&lt;img src="images/logo.gif" width="160px" height="90px" alt="Tunes. Get Music Now!" /&gt;');
}
//--&gt;
&lt;/script&gt;
&lt;noscript&gt;&lt;p&gt;&lt;img src="images/logo.gif" width="160px" height="90px" alt="Tunes. Get Music Now!" /&gt;&lt;/p&gt;&lt;/noscript&gt;&lt;/div&gt;&lt;!--End Header --&gt;

and flash.js
<i>
</i>// JavaScript Document

// FLASH DETECTION

// If Javascript is enabled:
// This script detects if Flash v6+ is installed.
// If Flash is installed:
// Then the .swf logo is displayed on the page.
// If Flash isnt installed:
// Then the .gif logo is displayed on the page.

// If Javascript isnt enabled:
// Then the .gif logo is displayed on the page.
// If Images arent enabled:
// Then the alternate text is displayed.

// I have found this to be useful as long as the .swf has no functionality
// and is only there for design purposes.

// Although the .gif may include some information letting the end user know that
// Javascript needs to be enabled and that the latest version of Flash needs to be installed.


// I adapted this script off the Big Brother website http://bigbrother.3mobile.com.au


var flashInstalled = false;
var isIE = (navigator.userAgent.indexOf("MSIE") != -1) ? true : false; <br/>
var isWin = (navigator.userAgent.indexOf("Win") != -1) ? true : false;

if (navigator.plugins &amp;&amp; navigator.plugins.length){
var x = navigator.plugins["Shockwave Flash"];
if (x){
if (x.description){
y = x.description;
var flashVersion = y.charAt(y.indexOf('.')-1); //checks flash version
if (flashVersion&gt;=6){ //checks for version 6 and above.
flashInstalled = true;
}
}
}
}

if(isIE &amp;&amp; isWin){ //can't read from plugins array on ie pc...
document.write('&lt;scr' + 'ipt language=VBScript&gt; n');
document.write('on error resume next n');
document.write('flashInstalled = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) n'); <br/>
document.write('flashInstalled = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) n'); <br/>
document.write('&lt;/scr' + 'ipt&gt; n');
}
Copy linkTweet thisAlerts:
@gavin26erauthorNov 29.2005 — hi

i tryed that man and it didn't work, i put the first part in to the html code, and the second part into the flash file like you said and re-named everything but, it still won't work. is there something i'm doing wrong i've attached the files so you could have a look.

[upl-file uuid=401d7c03-0bdd-4707-8904-f8a385db4dfd size=5kB]New_Folder.zip[/upl-file]
Copy linkTweet thisAlerts:
@bathurst_guyNov 29.2005 — <i>
</i>&lt;HTML&gt;
&lt;HEAD&gt;
&lt;meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1"&gt;
&lt;TITLE&gt;Untitled-1&lt;/TITLE&gt;
&lt;/HEAD&gt;
&lt;BODY bgcolor="#99CC00"&gt;

&lt;script type="text/javascript"&gt;
&lt;!--
var flashInstalled = false;
var isIE = (navigator.userAgent.indexOf("MSIE") != -1) ? true : false; <br/>
var isWin = (navigator.userAgent.indexOf("Win") != -1) ? true : false;

if (navigator.plugins &amp;&amp; navigator.plugins.length){
var x = navigator.plugins["Shockwave Flash"];
if (x){
if (x.description){
y = x.description;
var flashVersion = y.charAt(y.indexOf('.')-1); //checks flash version
if (flashVersion&gt;=6){ //checks for version 6 and above.
flashInstalled = true;
}
}
}
}

if(isIE &amp;&amp; isWin){ //can't read from plugins array on ie pc...
document.write('&lt;scr' + 'ipt language=VBScript&gt; n');
document.write('on error resume next n');
document.write('flashInstalled = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) n'); <br/>
document.write('flashInstalled = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) n'); <br/>
document.write('&lt;/scr' + 'ipt&gt; n');
}


if (flashInstalled){
document.write ('&lt;object type="application/x-shockwave-flash" data="Untitled-1.swf" width="760" height="120"&gt;');
document.write ('&lt;param name="movie" value="Untitled-1.swf" width="760" height="120" quality="high" menu="false" /&gt;');
document.write ('&lt;/object&gt;');
}
else {
document.write ('&lt;img src="Untitled-1.jpg" width="760" height="120" alt="Tunes. Get Music Now!" /&gt;');
}
//--&gt;
&lt;/script&gt;
&lt;noscript&gt;&lt;p&gt;&lt;img src="Untitled-1.jpg" width="760" height="120" alt="Tunes. Get Music Now!" /&gt;&lt;/p&gt;&lt;/noscript&gt;&lt;/div&gt;


&lt;/BODY&gt;

&lt;/HTML&gt;
Copy linkTweet thisAlerts:
@gavin26erauthorNov 30.2005 — hi guys

got another problem i got this java code off of bathurst guy it does what i want it do, but there are a few problems.

  • 1. is that there is a little dead space under the picture if the swf don't display and i don't know how to get rid of it.


  • 2. is now it don't prompt you and ask you if you want to download flash anymore. i want it to prompt me and if you say don't apply it displays the default pic and. please check out the uploaded file for reference.


  • gavin

    [upl-file uuid=4b9e70d3-e96d-4988-a95b-1d722447a34d size=5kB]New_Folder.zip[/upl-file]
    ×

    Success!

    Help @gavin26er 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 6.16,
    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: @nearjob,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

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