Solved

This is a Domino Web Application How to display replace a flash file on a page with a static image if flash is not installed on a PC. This is an extension of question Q_22959568.html

Posted on 2007-11-29
15
259 Views
Last Modified: 2013-12-18
In Q_22959568.html we resolved the problem of displaying "Click here to activate this control" when  mouseover on a flash file

Now, I have this other problem

I have a second image, not a flash file which I want to display is flash is not detected in the browser.
For example, if flash is disabled or the user doesn't have flash installed, image1.gif should display otherwise image2.swf should display

The solution in question Q_22959568.html was sufficient to resolve the mouseover problem(please refer to it for more info)

I have the following on the page that's suppose to display the flash OR image if flash is not installed

<p align=right>
<script LANGUAGE="JavaScript">
var ShockExist = 0;
if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
if (navigator.plugins && navigator.plugins["Shockwave Flash"])
ShockExist = 1;
} if (ShockExist ) {

<script src='flash.js' type='text/javascript'></script>

} else if (!(navigator.appName && navigator.appName.indexOf("Netscape")>=0 && navigator.appVersion.indexOf("2.")>=0))
{
<script src='flash1.js' type='text/javascript'></script>
}
</p>

Where

flash.js is the file that has my flash image object

flash1.js is the file that has my normal image object and this suppose to display instead of flash image if flash plugin is not installed

I don't know if I am doing the right thing or there is a better way for this to work so any help or advise from the experts will be much appreciated

Thanks
Varvoura
0
Comment
Question by:varvoura
  • 8
  • 5
  • 2
15 Comments
 
LVL 31

Assisted Solution

by:qwaletee
qwaletee earned 100 total points
ID: 20379473
I would just incorporate the script from the two files into m if /else if blocks. I've not seen the syntax of including another scirpt via a script src tag in middle of a block of code.


Alternatively, if the other two JS files contain only FUNCTIONS that you wish to call, then you can include their script src tags at the top, and just include the call to their functions in the if / else if blocks.
0
 

Author Comment

by:varvoura
ID: 20379566
qwaletee,

I have tried all that

maybe you can give me a tip on how to call them in a if/else correclty at the top of the page as this is where I am going wrong

So

for example,

I have 2 files

filea.js
fileb.js

filea.js contains the flash file that I wish to execute if flash plugin exists on PC
fileb.js contains the image file that I wish to execute if flash plugin doesn't exist on PC

I did have the following at the top of the page

<!--
var ShockMode = 0;
if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)
{
         if (navigator.plugins && navigator.plugins["Shockwave Flash"])
         {
                     ShockExist = 1;
         }
}
if (ShockExist )
{

<script src='filea.js' type='text/javascript'></script>

}
else
{
         if (!(navigator.appName && navigator.appName.indexOf("Netscape")>=0 && navigator.appVersion.indexOf("2.")>=0))  
         {  
                 <script src='fileb.js' type='text/javascript'></script>

}
}

This is an if/else statement  & is not working for me

Sorry but I still need a hand with this. Any other ideas?



0
 

Author Comment

by:varvoura
ID: 20379585
Hi qwaletee,

I forgot to mention that the 2 js files are not really functions but are more description of the flash file and image to be displayed

please refer to Q_22959568.html  for filea.js description, the code in that question is created in filea.js

& the content of fileb.js is as follows:

document.writeln('<object width="100" height="100">');
document.writeln('<IMG SRC="image2.jpg">');
document.writeln('</object>');

Thanks
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 20379592
Like I said, take the content of the two files and put them in-line.
0
 

Author Comment

by:varvoura
ID: 20379657
qwaletee,

This is not going to work

a) I can't place the content of those 2 files on the page because I will end up with the "Click here to activate this control" on the flash file

This is the main reason why I had to create those in separate files and call them on the page as I am calling them above
i.e  
<script src='filea.js' type='text/javascript'></script>

BTW, they do work when I place them directly on the page and they have always worked but with that
I will get "click here to activate this control"
WHICH IS THE MAIN REASON WHY Q_22959568.html was raised & the suggestion in it to create in the object in a separate file was introducted

THIS IS WHY, I HAVE ASKED THAT YOU REVIEW Q_22959568.html
Sorry qwaletee, If I sound a bit frusturated. I do appreciate your help but please review Q_22959568.html  to see what I am trying to get at with this new question

Thanks a million
 
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 20387428
As Qwaletee says, in-line scripting won't work (probably). The standard way to handle this is to write your included filea.js file as a function, and call that funtion. So, instead of having the following code in filea.js:

      if(.....) {
            etc...
      }

you make it a function:

function filea() {
      if(.....) {
            etc...
      }
}

Then, you ALWAYS include the filea.js file in your page, in the HEAD section:
<script .... src=".../filea.js"></script>

Your code in the page then will be somethink like this:

<!--
var ShockMode = 0;
if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)
{
         if (navigator.plugins && navigator.plugins["Shockwave Flash"])
         {
                     ShockExist = 1;
         }
}
if (ShockExist )
{
      filea();
}
else
{
         if (!(navigator.appName && navigator.appName.indexOf("Netscape")>=0 && navigator.appVersion.indexOf("2.")>=0))  
         {  
                 filea();
      }
}

Does this contain the clues you need?
0
 

Author Comment

by:varvoura
ID: 20387734
sjef, yes. However, this is not working the way it is suppose to work.

I have tried to insert the contents of the 2 files filea.js and fileb.js in functions then called them on the page as detailed above, but they don't seem to work. I have incase them as passthru html

A few things:

1. None of the 2 files "filea.js" or "fileb.js" have any if..else conditions, they are just descriptions of the objects that need to display depending on the browser conidtion(to whether or not a flash is installed)

2. Example of filea.js (as I had it before your suggestion)
document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="image1" width="200" height="100"  codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=3,0,0,0">');
document.writeln('<param name="movie" value="image1.swf">');
document.writeln('<param name="quality" value="high">');
document.writeln('<param name="play" value="true">');
document.writeln('<param name="loop" value="true">');
document.writeln('<param name="bgcolor" value="#000000">');
document.writeln('<param name="Wmode" value="transparent">');
document.writeln('</object>');

(the above is in filea.js and NOT IN PASSTHRU HTML)

Then a call on the page at  the location where I want to insert the flash file is as follows

<script src='filea.js' type='text/javascript'></script>

And the HTML HEAD CONTENT ALSO CONTAINS

<script src='filea.js' type='text/javascript'></script>

ALL THE ABOVE WORKS FINE

Now, to insert image2.gif if flash does not exist on PC or is not detected, I have created another file and called it fileb.js

Content of fileb.js is as follows, which is again ONLY a description of the image2.gif object that's suppose to substitute image1.swf if flash not detected      

document.writeln('<object width="200" height="100">');
document.writeln('<IMG SRC="image2.gif">');
document.writeln('</object>');

if I place a call on the page to where I want to insert this image as follows, it also works

<script src='filea.js' type='text/javascript'></script>

Again the <script src='filea.js' type='text/javascript'></script>
is inserted in the HTML HEAD CONTENT OF THE PAGE

NOW, following suggestion of qwaletee & sjef, I have incased both filea.js and fileb.js in function as follows:

Page "filea.js" now contains the following:

function filea(){
document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="pirtek-134222-new" width="250" height="100"  codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=3,0,0,0">');
document.writeln('<param name="movie" value="pirtek-134222-new.swf">');
document.writeln('<param name="quality" value="high">');
document.writeln('<param name="play" value="true">');
document.writeln('<param name="loop" value="true">');
document.writeln('<param name="bgcolor" value="#000000">');
document.writeln('<param name="Wmode" value="transparent">');
document.writeln('</object>');
}


page "fileb.js" now contains the following

function fileb(){
document.writeln('<object width="250" height="100">');
document.writeln('<IMG SRC="pirtek-134222-new.gif">');
document.writeln('</object>');
}
 
In the HTML HEAD CONTENT OF MY PAGE (where i want the object inserted) I have the following

<script src='filea.js' type='text/javascript'></script>
<script src='fileb.js' type='text/javascript'></script>

Then in the location where I want image1.swf or image2.gif inserted I have the following(in passthru html)

<!--
var ShockExist = 0;
if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin)
{
         if (navigator.plugins && navigator.plugins["Shockwave Flash"])
         {
                     ShockExist = 1;
         }
}
if (ShockExist )
{
      filea();
}
else
{
         if (!(navigator.appName && navigator.appName.indexOf("Netscape")>=0 && navigator.appVersion.indexOf("2.")>=0))  
         {  
                 fileb();
      }
}


..And all that is not working.
In fact, I get the "the text above in the if ...else" condition displaying on my page instead of the images

I have even tried to disable the content to normal text as opposed to passthru html (i know its silly) but still didn't work

I have also tried to place the above functions filea() and fileb() in js header as opposed to separate pages and this also didn't work

I do apologise for the long long story. I hope it made sense

Thanks

 


0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 20387868
I hope you enclosed the javascript in <script>...</script> tags? It seems that the JS isn't interpreted at all. Ans I like the JS Header idea a lot, so you can get rid of the separate files.
0
 

Author Comment

by:varvoura
ID: 20387885
Of course I did enclose the js in <script>....</script> tags

I may try it again using the JS header.
I'll post the results shortly



0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 20387948
Otherwise, send me just a copy of the form, in a new database.
0
 

Author Comment

by:varvoura
ID: 20387970
So close

I have create filea() and fileb() as described above in JS header

Then I pasted the following in the location of the page where the one of the objects suppose to appear.
<script LANGUAGE="JavaScript">
if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
if (navigator.plugins && navigator.plugins["Shockwave Flash"])
fileb()
} else if (!(navigator.appName && navigator.appName.indexOf("Netscape")>=0 && navigator.appVersion.indexOf("2.")>=0))
{  
filea()
}
</script>

It seems that the "else..." condition only execute when the
Which means only fileb() which is static image only executing

using the me as above code in the onload event seems to work fine
I usually try both by enabling & disabling shockwave plugin from IE options

sjef, I will send you the one page with my code above included,
Thank you in advance
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 20388013
You can do this differently, more like this:

<script LANGUAGE="JavaScript">
var flashie= false, flashns=false;
if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
if (navigator.plugins && navigator.plugins["Shockwave Flash"])
flashie=true;
}
if (!(navigator.appName && navigator.appName.indexOf("Netscape")>=0 && navigator.appVersion.indexOf("2.")>=0))
{  
flashns= true;
}
if(flashie)
      fileb();
else if(flashns)
      filea();
else
      filec();
</script>

So use the logic to get the flags, then use the flags to activate the right function.
0
 

Author Comment

by:varvoura
ID: 20390024
sjef, still the same, the else condition only executes

I have a feeling it has more to do with the checking in the "if..else" with the shockwave plugin types.

Are you able to try this yourself to see if it works for you?

I know it maybe a lot of trouble but even if you can create 2 of your own files 1) a .swf and .gif as image resources and try the above with it

The only reason for my last suggestions is that I have tried so many different variations & I am only getting the execution of the else condition
Even when I place fileb() in the else condition it seems to work fine.
else if(flashns)
      fileb();

flash works fine (considering that flash is enabled in browser)

Thanks
0
 

Author Comment

by:varvoura
ID: 20390034
qwaletee,

Looking at sjef's comments above, can you make anything out of the error/problem that I am getting

What is it that only the "else condition" is executing?

Thanks
0
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 400 total points
ID: 20390649
Okay, I got your mail. Everything seems okay to me, so it must be the logic that's not quite what you want. The problem as you described it earlier is that "I have the following on the page that's suppose to display the flash OR image if flash is not installed".

Translating this into mock-javascript:
if(flash_present())
      display_flash();
else
      display_image();

That leaves the function flash_present() to be defined, something like this:
function flash_present() {
      if(this_is_IE())
            if(IE_got_flash())
                  return true;
      if(this_is_Netscape())
            if(Netscape_got_flash())
                  return true;
      return false;
}

You can define the other functions yourself, my knowledge of finding out if flash is present is... er... limited... ;-))
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now