Patrick Burt - A Blog for Web People

SWFObject Strange Validation Problem

Tuesday, July 3rd, 2007

Categories: Troubleshooting, SWFObject

RSS Comment Feed

Trackback

AddThis Social Bookmark Button

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.

Bookmark this blog using any bookmark manager!

Our new full escort Praha catalogue with real photos.

Related Posts


Subscribe to this Post

7 Responses to “SWFObject Strange Validation Problem”

  1. jeff Says:

    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.

  2. Patrick Burt Says:

    Hahaha, I definitely know the feeling Jeff.

  3. Will Says:

    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.

  4. Patrick Burt Says:

    It certainly does Will. I had a look at the newest version and the lines in questions are 89 and 101.

  5. chieri Says:

    i still get the error after removing ” style=”‘+ this.getAttribute(’style’) +’ from those two lines … any ideas?

  6. Patrick Burt Says:

    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

  7. chieri Says:

    thank you, patrick.

    that fixed it.

Leave a Reply