[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4838
  • Last Modified:

swfobject is undefined error only in IE Internet Explorer

Happy New year to all!

I am trying to set up swfobject.js and getting an error in Internet Explorer only, although I have only tested otherwise in Firefox.

The attached code is from the swfobject documentation. All files are in the same folder.
swobject.js, expressinstall.swf, and KingReport.swf are all present in the folder with the html page being called by the browser.

When the page is rendered the error generated is " error line 8:  'swfobject' is undefined".

After the error message is cleared the page processes and the flash content is shown.

TIA!


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
	<head>
		<title></title>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
		<script type="text/javascript" src="swfobject.js"></script>
		<script type="text/javascript">
			swfobject.registerObject("myFlashContent", "9.0.0", "expressinstall.swf");
		</script>
	</head>
	<body>
		<div>
			<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="800" height="1100" id="myFlashContent">
				<param name="movie" value="KingReport.swf" />
				<!--[if !IE]>-->
				<object type="application/x-shockwave-flash" data="KingReport.swf" width="800" height="1100" id="myFlashContent">
				<!--<![endif]-->
					<a href="http://www.adobe.com/go/getflashplayer">
						<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
					</a>
				<!--[if !IE]>-->
				</object>
				<!--<![endif]-->
			</object>
		</div>
	</body>
</html>

Open in new window

0
Spitfire6
Asked:
Spitfire6
  • 6
  • 6
1 Solution
 
fsze88Commented:
this is my sample
http://www.kennam.com/test/swfobj.html
works on ie,ff,safari,opera.....
<script type="text/javascript" src="/js/swfobject/swfobject.js"></script>

<script type="text/javascript">
  var msieRegex = /msie/ig;
  var movieWidth, movieHeight;
	var flashvars = {};
  var params = {};
  var attributes = {};

  var params = {
			allowFullScreen: "true",
			allowScriptAccess: "always",
			wmode: "transparent",
			menu: "true",
			scale: "exactfit",
			base: "/video/source/"
		};



  if (msieRegex.test(navigator.userAgent)){
    movieWidth = document.body.clientWidth;
    movieHeight = document.body.clientHeight;
  }else{
    movieWidth = window.innerWidth;
    movieHeight = window.innerHeight;
  }
  movieWidth = parseInt(movieWidth * 0.5);
  movieHeight = parseInt(movieWidth /16 * 9) + 50;


window.onload = function(){
swfobject.embedSWF("/video/source/tissuepaper1.swf", "myContent", new String(movieWidth), new String(movieHeight), "9.0.0", "expressInstall.swf", flashvars, params, attributes);
}

</script>

<div id="myContent">
</div>

Open in new window

0
 
Spitfire6Author Commented:
Thanks for the reply fsze88,

I gave your code a try and am getting "error line 21: object required".

I see where you set the var msieRegex at line 4, but I don't understand what you are setting it to.

Tnx,

Mike

0
 
fsze88Commented:
it is for screen adjustment. not need for your case.
http://www.kennam.com/test/swfobject2.html

in your case, try to use
window.onload = function(){
swfobject.registerObject("myFlashContent", "9.0.0", "expressinstall.swf");
}

should okey
<script type="text/javascript" src="/js/swfobject/swfobject.js"></script>

<script type="text/javascript">
  var movieWidth, movieHeight;
	var flashvars = {};
  var params = {};
  var attributes = {};

  var params = {
			allowFullScreen: "true",
			allowScriptAccess: "always",
			wmode: "transparent",
			menu: "true",
			scale: "exactfit",
			base: "/video/source/"
		};

  movieWidth = 800;
  movieHeight = 600;

window.onload = function(){
swfobject.embedSWF("/video/source/tissuepaper1.swf", "myContent", new String(movieWidth), new String(movieHeight), "9.0.0", "expressInstall.swf", flashvars, params, attributes);
}

</script>

<div id="myContent">
</div>

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Spitfire6Author Commented:
Modified your code slightly, as below.

All files are in the same folder as the html file being retreived.

Still get "Error Line 21 -swfobject is undefined"
<script type="text/javascript" src="swfobject.js"></script>

<script type="text/javascript">
  var movieWidth, movieHeight;
        var flashvars = {};
  var params = {};
  var attributes = {};

  var params = {
                        allowFullScreen: "true",
                        allowScriptAccess: "always",
                        wmode: "transparent",
                        menu: "true",
                        scale: "exactfit",
                        base: "/video/source/"
                };

  movieWidth = 800;
  movieHeight = 1100;

window.onload = function(){
swfobject.embedSWF("KingReport.swf", "myContent", new String(movieWidth), new String(movieHeight), "9.0.0", "expressInstall.swf", flashvars, params, attributes);
}

</script>

<div id="myContent">
</div>

Open in new window

0
 
fsze88Commented:
is it works on ff or ie?
1) clear your browser (ff or ie) cache
2) append './' on front of each file path e.g. <script type="text/javascript" src="./swfobject.js"></script>
what browser issue come from ? (ff or ie)?
0
 
Spitfire6Author Commented:
Thanks for staying with this fsze88!

Originally, with my code at the top of this thread, It was working in FF but not IE. Your latest code is not working in either browser.

I have added ./ ahead of all files as suggested. No difference in IE - "Error line 21: swf object is undefined".
I do not have FF set to render error messages. FF just shows a blank page.
0
 
fsze88Commented:
Spitfire6,
did you tried example on http://www.kennam.com/test/swfobj.html? 
it is works on my computers, if doesn't work on yours, this may a problem cause from your browser
as you said there an error "Error line 21: swf object is undefined", but that flash is shown up after that error.
This should cause of wrong path or missed of swfobject.js file
That flash was shown up because of you are using <object> tag, doesn't matter of swfobject.js object.
the easiest way to test swfobject there? please have a try at code attachment.
if still swfobject is undefined, please check the file swfobject.js and path of it

<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
window.onload = function(){alert(swfobject);}
</script>

Open in new window

0
 
Spitfire6Author Commented:
Well this is very strange!

Your code above results in the same error: "swfobject is undefined". This is both in IE and FF. I am sure that the error has been present in FF all along but I did not check the FF error console. FF just bypassed the error and processed the rest of the page.

I have verified that swfobject.js is present in the correct locations (I currently have a copy in the site root and in two different sub-folders).

I can hit swfobject.js directly using the url (http://www.xxxxxxxxx.com/swfobject.js). When doing so I get the file info and print out of the script in my browser window. So I know the file is there.

I have tested using another computer. Same results.

????
0
 
fsze88Commented:
Please try goto http://www.kennam.com/test/swfobj.html
and also what is your ff or version
0
 
Spitfire6Author Commented:
Hello,

That link works fine. Nice big printer.

MY FF is version 3.0.16. IE is 6.0.29
0
 
fsze88Commented:
this issue may because of your swfobject.js file
please try to update this file from
http://code.google.com/p/swfobject/downloads/list
and try it again.
0
 
Spitfire6Author Commented:
Thanks fsze88! That was the problem.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now