My favorites | Sign in
Project Logo
                
New issue | Search
for
| Advanced search | Search tips
Issue 332: swfobject 2.2 inclusion throws JS error
14 people starred this issue and may be notified of changes. Back to list
Status:  Accepted
Owner:  ----
Type-Defect
Priority-Medium


Sign in to add a comment
 
Reported by MartijnStevenson, Jun 29, 2009
What steps will reproduce the problem?

Just including swfobject 2.2 (page head section) with a certain config (see
below).

What is the expected output? What do you see instead?

Firebug reports a JavaScript error like:
   "Error calling method on NPObject!"
Stack trace goes to this line:
   var d = t.GetVariable("$version");

What version of the product are you using? On what operating system?
swfobject v2.2, Windows (Server 2003), FireFox 3.0.11, downgrade to Flash
8.0.22

Please provide any additional information below.

I was able to fix locally by simply surrounding the one line with a
try/catch. All other functionality seems to be fine.
Comment 1 by bobbyvandersluis, Jun 29, 2009
With this config, if you browse to our test suite you see the same error?
- http://www.bobbyvandersluis.com/swfobject/testsuite_2_2/test.html
- http://www.bobbyvandersluis.com/swfobject/testsuite_2_2/test_dynamic.html

If you open the Tools > Error console, do you see the same error displayed here?

And it only happens when you downgrade to Flash 8, not in later versions?
Comment 3 by bobbyvandersluis, Jun 30, 2009
For SWFObject it doesn't matter which version you target. Do you test locally? If so,
what if you put your files on a Web server?
Comment 4 by MartijnStevenson, Jun 30, 2009
I tried both your test suite, and the test suite included with swfobject 2.2
(ostensibly the same code?). I do not get the error using either. However, the test
suite targets Flash 9 and I do not see the alternative content.

When I target my local swfobject 2.2 test suite to Flash 8 (my installed version), I
do see the error on both pages (static and dynamic) and I see no movie.

When I apply my fix (try/catch) to my local swfobject 2.2 test suite, targeted to
Flash 9, the alternative content does appear and there is no error.

When I apply my fix (try/catch) to my local swfobject 2.2 test suite, targeted to
Flash 8, the test movie does appear and there is no error.

Problem appears in:
* Flash Player 8.0.22 (first v8 player)
* Flash Player 8.0.42 (last v8 player)

Problem does not appear in:
* Flash Player 9.0.15 (first v9 player)
* Internet Explorer (7)
* Chrome (2)
* Safari (3)

Comment 5 by MartijnStevenson, Jun 30, 2009
I tested across machines (with the host running a web server).

I believe you that the target version does not affect the movie rendering, but I bet
it affects the code path taken in the swfobject library (rendering the movie vs. the
alternative content).
Comment 6 by MartijnStevenson, Jun 30, 2009
I want to clarify my original bug report. I said the steps to reproduce were:
"Just including swfobject 2.2 (page head section) with a certain config (see
below)."

I am not sure that was accurate. I never tested just including the swfobject library.
I was always loading at least one movie as well.
Comment 7 by bobbyvandersluis, Jul 01, 2009
"Error calling method on NPObject!" on Firefox is usually caused by a security issue,
so I think something might be wrong with running things on a local server. I mean,
the code executes fine, GetVariable functionality is accessible, however the object
can not be accessed due to browser security constraints. That would also explain why
the files from the test suite are working correctly.

I see no cause for a SWFObject bug, if you would like to discuss/examine it further,
please repost the issue in the discussion group: http://groups.google.com/group/swfobject
Status: Invalid
Comment 9 by MartijnStevenson, Jul 01, 2009
I'm not running this on a local server. I'm running this from one machine to an IIS
server on another machine... Have you tried to reproduce this yourself and been
unsuccessful?

Comment 10 by MartijnStevenson, Jul 01, 2009
Also, the files from the test suite are *not* working correctly. No alternative
content is displayed, and when you decrease the required Flash version to 8, you do
see the error.
Comment 11 by bobbyvandersluis, Jul 01, 2009
As I have said before, if I look at the error description I'm not convinced that this
issue is caused by SWFObject. It could be a security issue that has something to do
with your implementation or it could have something to do with the archived FP8
versions. 

Due to time constraints we only investigate issues of which we think they could be
caused by SWFObject, it's not up to us to prove you wrong. So for now your issue is
logged, if you'd like to discuss it further, please use the discussion group.

Comment 12 by MartijnStevenson, Jul 01, 2009
Fair enough. I've patched my local version, but I want to add some more information
to the record:

Normally these errors are security issues, as you mentioned. It's usually people
doing cross-domain flash calls without the correct domain permissions. In that case,
the fix would be to pass the proper access level in the allowscriptaccess param.

In this case the problem is reproducible by calling
swfobject.getFlashPlayerVersion(), without loading *any* of my own Flash content.
Comment 13 by getify, Jul 06, 2009
I just confirmed/reproduced this error with FF3.0.11 on WinXP SP3, with FP 8.0.22 
installed. I simply went to the first dynamic embed test suite page:

http://www.bobbyvandersluis.com/swfobject/testsuite_2_2/test_dynamic.html

And the error was reported. The error also occurred with FP 8.0.42 installed. But 
did *not* occur with FP 9.0.16 installed.

I also tried the above tests with the 2.1 test suite, and no errors occurred. So 
this is definitely a regression. Not sure why though. But we should look into it.
Status: Accepted
Comment 14 by schwarzenneger2000, Jul 12, 2009
Error reproduced on:
--------------------
* Firefox 3.0.11
* Windows XP SP3
* Flash Player 8.0 r22 (Debug version)

Additional information:
--------------------
In my code, I am requesting minimum SWF version = 8, which is same version as the one
installed in browser, but I am receiving the "Error calling method on NPObject!".

The code can be viewed at:
--------------------------
http://911-need-code-help.blogspot.com/2009/05/embed-youtube-videos-in-your-web.html

The code snippet:
-----------------
  <script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/swfobject/2/swfobject.js"></script>

  <a name="ytplayer1"></a>
  <div id="ytplayer1_div">You need Flash player 8+ and JavaScript enabled to view
this video.</div>
  <script type="text/javascript">
    swfobject.embedSWF(
      'http://www.youtube.com/v/21OH0wlkfbc&enablejsapi=1&rel=0&fs=1',
      'ytplayer1_div',
      '425',
      '344',
      '8',
      null,
      null,
      {
        allowScriptAccess: 'always',
        allowFullScreen: 'true'
      },
      {
        id: 'ytplayer1_object'
      }
    );
  </script>

Output:
-------
* A div containing the message:

You need Flash player 8+ and JavaScript enabled to view this video.

* The error "Error calling method on NPObject!"

Comment 15 by martin.h...@hobnox.com, Sep 14, 2009
Experiencing same problems here too - no error occurs with swfobject 1.1!
Comment 16 by aran.rhee, Oct 12, 2009
 Issue 389  has been merged into this issue.
Comment 17 by brains.for.rent, Oct 19, 2009
I can confirm this. Our content requires FP9, swfobject 2.2 fails to fall back when 
FP8 is installed and dynamic publishing method is used.
Comment 18 by brains.for.rent, Oct 19, 2009
Follow-up for comment #17. Here's some minimal code for reproduction:

1) Install any Flash Player 8 (I used 8.0r24) in Firefox (I used 3.5.3).

2) Maka a simple test page with swfobject 2.2 but no embedded swf:

  <html>
    <head>
      <script src="swfobject22.js" type="text/javascript"></script>
    </head>
    <body>
      <script type="text/javascript">
        if(swfobject.hasFlashPlayerVersion("9.0.0"))
          alert("FP 9 or newer")
        else 
          alert("FP 8 or older");
      </script>
  </body>
</html>

this displays the alert but also causes a JS error: "Error calling method on 
NPObject!" in swfobject22.js line 4. It proves the problem is in swfobject and not 
in loaded content.

3. Create another test page:

  <html>
    <head>
      <script src="swfobject22.js" type="text/javascript"></script>
    </head>
    <body>
      <div id="mydiv">This page needs Flash Player 9+</div>
      <script type="text/javascript">
        swfobject.embedSWF("needf9.swf", "mydiv", "500", "400", "9.0.0");        
      </script>
    </body>
  </html>

This CLEARS the content of the div and THEN produces the JS error, leaving the div 
empty.

Comment 19 by Niakmo, Oct 19, 2009
I can confirm having the same issue:

<script type="text/javascript">
			
			var fv = swfobject.getFlashPlayerVersion();
			
			alert(fv.major);
			var flashvars = {};
			var params = {};
			params.bgcolor = "#000000";
			params.allowfullscreen = "true";
			var attributes = {};
			attributes.id = "mainMovie";
			swfobject.embedSWF("main.swf?v=0.8.4", "nonFlashContent", "100%", "100%", "9",
"flash/expressInstall.swf", flashvars, params, attributes);
		</script>

The alert displays version 8, after you click ok on the alertbox the error is displayed.
Comment 20 by mocodere, Nov 03, 2009
I had the exact same issue and using:

try
{
     var d = t.GetVariable("$version");
} catch(err) {
     //Handle errors here
}

instead of just:

var d = t.GetVariable("$version");

Worked great!

I'm a newbie on code.google.com, but why does the correction hasn't been made yet? It
just works!
Comment 21 by felix.na...@googlemail.com, Dec 17, 2009
Same problem here with flash 8 and below. 

The fix http://code.google.com/p/swfobject/issues/detail?id=332#c20 by mocodere does
work for me, just try it! Thanks mocodere. There are over a dozen people having this
problem. How many must report till theres a official fix?
Sign in to add a comment

Hosted by Google Code