SWFObject Strange Validation Problem
Tuesday, July 3rd, 2007Categories: SWFObject, Troubleshooting
RSS Comment Feed
Trackback
Warning: Expected ‘:’ but found ‘undefined’. Declaration dropped.
If you have no idea what SWFObject is, you can find an article here. Chances are, if you use SWFObject and you care about having a site that validates, you will come across this very minor problem. If you’re new to validation, don’t worry. This isn’t something to get all ruffled about. It’s simply means your SWFObject code is one step away from perfection.
The Problem
The problem is that SWFObject is creating a field similar to style=”". This will never validate.
Note: You will never see this by hitting View Source simply because Javascript (the language in which SWFObject is created) is executed by your browser after seeing the HTML source; whereas languages like PHP and ASP generate HTML source before your browser retrieves it.
The Solution
It’s good to know that the solution to this validation problem is a quick fix. If you open your swfobject.js file. In there, you’ll have to modify the two longest lines, they start with:
swfNode = ‘<embed type=”application/x-shockwave-flash”
swfNode = ‘<object id=”‘+ this.getAttribute(‘id’)
Further down both these lines you will have to remove:
” style=”‘+ this.getAttribute(‘style’) +’
What this does is prevent SWFObject from ever writing style=”" code (you’re going to use a div container anyway, no big loss). Not a character after, not a character before. Take off starting at the double quote, and take off the single quote.
If you’re still looking for them, both instances are located on lines 89 and 101. Also, if it seemed like you tried everything and something went bonkers. You can click here to download the fixed SWFObject.
Now if you’re having problems getting your site to Validate, it won’t be SWFObject.

Error. Page cannot be displayed. Please contact your service provider for more details. (11)
Related Posts
- SWFObject 2.0 and New Website
- Devil’s Advocate – Why You Shouldn’t Use SWFObject
- Loading Variables From Query String Into Flash
July 27th, 2007 at 3:07 pm
thanks! I guess I could understand why that would be in there, but whatever.
I know that this didn’t affect my page, but not having the 3 green checks on my developer toolbar got to me.
July 29th, 2007 at 5:40 pm
Hahaha, I definitely know the feeling Jeff.
September 14th, 2007 at 11:41 am
Does this correction apply to swjObject v1.5?
I don’t see the code block you mentioned in that version.
There is a line that is close but starts and ends in double quotes.
September 14th, 2007 at 11:58 am
It certainly does Will. I had a look at the newest version and the lines in questions are 89 and 101.
October 3rd, 2007 at 5:58 pm
i still get the error after removing ” style=”‘+ this.getAttribute(’style’) +’ from those two lines … any ideas?
October 4th, 2007 at 8:11 am
Hi chieri, thanks for the comment.
It seems like something went wrong. I’ll include a link to my fixed SWFObject in the article: http://www.pat-burt.com/wp-content/uploads/swfobject.zip
October 4th, 2007 at 11:02 am
thank you, patrick.
that fixed it.
November 4th, 2008 at 12:40 am
Coming to this a bit late – but this fix hasn’t worked for me, even using the fixed swfobject download. Probably not hugely important, but it’s one of those niggling problems that just won’t leave me alone
November 7th, 2008 at 6:05 am
+”\” style=\”"+this.getAttribute(“style”)
The code above occurs twice in the script (v1.5) and I solved the problem by removing the first one.
Thanks for advice!
February 11th, 2012 at 5:57 am
Very great post. I just stumbled upon your weblog and wanted to say that I’ve really loved surfing around your weblog posts. In any case I will be subscribing for your rss feed and I hope you write once more soon!