By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,483 Members | 3,312 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,483 IT Pros & Developers. It's quick & easy.

Opera <NOSCRIPT> will be executed...Flash detection

P: n/a
Hello,
there is a known problem with Opera and the execution of content shown
in <NOSCRIPT> tag.

Everythings works fine, if there is only one simple script like:
http://www.dr-wald.de/test/Opera-NOSCRIPT.html

Switching off Javascript will show the alternative content. Javascript
enabled will only show the JS-content, _not_ the <NOSCRIPT> content.

But:
If there are some more scripts in a page, JS content _and_ alternative
<NOSCRIPT> content is shown, if there seems to be a script error or an
unknown script before executing the error script. This behavior is
according to the W3C, but IMHO not useful:
http://www.w3.org/TR/1998/REC-html40....html#h-18.3.1

I am developing a Flash browser detection working also with Opera, not
only Moz/IE: There shall be displayed an alternative content, if flash
is not supported or if flash version is to low.
Macromedia is providing a browser detection script, which works fine
with Opera, if _any_ flash version is installed.

But:
If _NO_ flash is installed (rename
c:\Programme\Opera72\Program\Plugins\NPSWF32.dll) javascript content
_and_ alternative <NOSCRIPT> content will be shown:
http://www.dr-wald.de/test/mainframetest.html

I do not know how to solve this problem!

There must be a problem with the following code:
<script type="text/javascript">
<!--
var contentVersion = 5;
var plugin = (navigator.mimeTypes &&
navigator.mimeTypes["application/x-shockwave-flash"]) ?
navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
var words = navigator.plugins["Shockwave Flash"].description.split(" ");
for (var i = 0; i < words.length; ++i)
{
if (isNaN(parseInt(words[i])))
continue;
var PluginVersion = words[i];
}
var FlashCanPlay = PluginVersion >= contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0
&& (navigator.appVersion.indexOf("Win") != -1)) {
[...]
Please, are there any hints?
X-Post2 comp.lang.javascript,opera.page-authoring
Fup2 comp.lang.javascript

--
Best regards/ MfG,
Gustav Medler
pm.gustav.medler (at) gmx.net
*Mail reply will not be read,
*please use address above!
Jul 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On Thu, 6 Nov 2003 08:52:46 +0100, "Gustav Medler"
<no*******@nurfuerspam.de> wrote:
there is a known problem with Opera and the execution of content shown
in <NOSCRIPT> tag.
No, as you suggest later, there's a known problem with the other UA's
and the HTML specification.
I do not know how to solve this problem!
NOSCRIPT is generally useless for the above reasons, avoid it, use
more appropriate methods to degrade (e.g. only have javascript write
content you're unsure about, use pure HTML approaches to degrading
flash - don't use flash...)
var plugin = (navigator.mimeTypes &&
This needs to check for a navigator object.
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0


This is flawed...

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #2

P: n/a
Jim Ley <ji*@jibbering.com> wrote/schrieb:
var plugin = (navigator.mimeTypes &&

This needs to check for a navigator object.
else if (navigator.userAgent &&
navigator.userAgent.indexOf("MSIE")>=0

This is flawed...


I do know the problems about the UA's espacially from Opera. In my
opinion a good resolution is not to detect the UA's but using
(!window.opera) or (window.opera). This is IMHO displayed every
time.....

But this issue doe not solve my problem described above.
--
Best regards/ MfG,
Gustav Medler
pm.gustav.medler (at) gmx.net
*Mail reply will not be read,
*please use address above!
Jul 20 '05 #3

P: n/a
On Thu, 6 Nov 2003 12:21:29 +0100, "Gustav Medler"
<no*******@nurfuerspam.de> wrote:
But this issue doe not solve my problem described above.


Yes, I addressed that in my other points - don't use NOSCRIPT, it's
flawed, using OBJECT or similar to just display the flash with
appropriate degrading, or only add the flash if you've successfully
detected that it's supported, and you can replace the fallback
content.

I don't really understand your actual problem - what are you putting
in NOSCRIPT that's so disastrous that it's displayed aswell as the
flash? if it's "install flash" then you're just misusing
web-authoring, your page should degrade.

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #4

P: n/a
Jim Ley <ji*@jibbering.com> wrote/schrieb:
Yes, I addressed that in my other points - don't use NOSCRIPT, it's
flawed, using OBJECT or similar to just display the flash with
appropriate degrading, or only add the flash if you've successfully
detected that it's supported, and you can replace the fallback
content.
That's it want I want to do in Javascript ;-)
But Opera seems to be a little bit particular especially if _no_ flash
plugin is installed. All tested cases are working under all
circumstances, NS4.7, Moz, Konqueror, IE. Only Opera shows the problem
of displaying script _and_ noscript content simultaneously.
I don't really understand your actual problem - what are you putting
in NOSCRIPT that's so disastrous that it's displayed aswell as the
flash? if it's "install flash" then you're just misusing
web-authoring, your page should degrade.


On the one hand the NOSCRIPT content shall be a static picture of the
animated content. I will not ask a visitor to install or update the
flash plugin, because in my opinion it will be boring for them.
On the second hand there are some layout problems if _no_ content is
displayed.

How to change this script for detecting that no plugin is installed in
an Opera browser?
[Example page at: http://www.dr-wald.de/test/mainframetest.html ]
<script type="text/javascript">
<!--
var contentVersion = 5;
var plugin = (navigator.mimeTypes &&
navigator.mimeTypes["application/x-shockwave-flash"]) ?
navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
var words = navigator.plugins["Shockwave Flash"].description.split(" ");
for (var i = 0; i < words.length; ++i)
{
if (isNaN(parseInt(words[i])))
continue;
var PluginVersion = words[i];
}
var FlashCanPlay = PluginVersion >= contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0
&& (navigator.appVersion.indexOf("Win") != -1)) {
[...]
--
Best regards/ MfG,
Gustav Medler
pm.gustav.medler (at) gmx.net
*Mail reply will not be read,
*please use address above!
Jul 20 '05 #5

P: n/a
On Thu, 6 Nov 2003 16:17:25 +0100, "Gustav Medler"
<no*******@nurfuerspam.de> wrote:
On the one hand the NOSCRIPT content shall be a static picture of the
animated content. I will not ask a visitor to install or update the
flash plugin, because in my opinion it will be boring for them.
Great, so use your script, detect flash, if it's found replace the
fallback image in the page with the flash, no need to do anything in
the situation where flash isn't detected, you just leave the document
as is, same as when script is disabled.
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0
&& (navigator.appVersion.indexOf("Win") != -1)) {


As I noted before, this script is flawed, your problem is a lot more
than opera with this approach.

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #6

P: n/a
Jim Ley <ji*@jibbering.com> wrote/schrieb:
Great, so use your script, detect flash, if it's found replace the
fallback image in the page with the flash, no need to do anything in
the situation where flash isn't detected, you just leave the document
as is, same as when script is disabled.


Resolution found!

Problem:
JS-Browser detection works fine if any version of flash plugin
(vers.2-7) is installed. If there is _NO_ flash plugin installed, SCRIPT
and NOSCRIPT content will be executed by Opera, pictures for example
will be shown twice.
This behavior is according to W3C because Opera does not know the
'SCRIPT LANGUAGE=VBScript' and will trade it as a script error with
execution of the NOSCRIPT content.
http://www.w3.org/TR/1998/REC-html40....html#h-18.3.1

Resolution:
This behaviour can be solved simply by adding 'window.opera &&' to this
line of the detection script:

else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0
&& (navigator.appVersion.indexOf("Win") != -1)) {

Better version:

else if (!window.opera && navigator.userAgent &&
navigator.userAgent.indexOf("MSIE")>=0 &&
(navigator.appVersion.indexOf("Win") != -1)) {

Browser detection in Opera is difficult because of spoofing, but IMHO
'Opera' will always be shown.....

The whole flash detection script works now including display of alternative
content
for 'too low flash version',
for 'no flash plugin detected/installed' and
for 'javascript disabled'
in NS4.7+, IE 5+, Opera5+, Moz1+, Konqueror3+ on Win32/Linux.

[Somebody surfing with MAC???]

Whole detection script:

<!-- Start Flash -->
<script type="text/javascript">
<!--
var contentVersion = 5;
var plugin = (navigator.mimeTypes &&
navigator.mimeTypes["application/x-shockwave-flash"]) ?
navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
var words = navigator.plugins["Shockwave Flash"].description.split(" ");
for (var i = 0; i < words.length; ++i)
{
if (isNaN(parseInt(words[i])))
continue;
var PluginVersion = words[i];
}
var FlashCanPlay = PluginVersion >= contentVersion;
}
else if (!window.opera && navigator.userAgent &&
navigator.userAgent.indexOf("MSIE")>=0 &&
(navigator.appVersion.indexOf("Win") != -1)) {
document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
document.write('on error resume next \n');
document.write('FlashCanPlay = (
IsObject(CreateObject("ShockwaveFlash.ShockwaveFla sh." &
contentVersion)))\n');
document.write('</SCR' + 'IPT\> \n');
}
if ( FlashCanPlay ) {
document.write('<OBJECT
classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflas
h.cab#version=6,0,0,0" ID="schloss_gr" WIDTH="365" HEIGHT="265">');
document.write('<PARAM NAME="movie" VALUE="schloss_gr.swf"><PARAM
NAME="quality" VALUE="high"><PARAM NAME="scale" VALUE="exactfit"><PARAM
NAME="bgcolor" VALUE="#E2E2E2">');
document.write('<EMBED src="schloss_gr.swf" quality="high"
scale="exactfit" bgcolor="#E2E2E2" swLiveConnect=FALSE WIDTH="365"
HEIGHT="265" NAME="schloss_gr" TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">');
document.write('</EMBED>');
document.write('</OBJECT>');
} else{
document.write('<a href="../start/index.html" target="_parent"><img
src="../index/schloss_gr.jpg" width="365" height="245" border="0"
alt="Praxis"></a>');}
//--></script>

<noscript>
<a href="../start/index.html" target="_parent"><img
src="../index/schloss_gr.jpg" width="365" height="245" border="0"
alt="Praxis"></a>
</noscript>
<!-- End Flash -->
--
Best regards/ MfG,
Gustav Medler
pm.gustav.medler (at) gmx.net
*Mail reply will not be read,
*please use address above!
Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.