SWFObject Strange Validation Problem

Tuesday, July 3rd, 2007

Categories: SWFObject, Troubleshooting

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!
Subscribe to Pat-Burt.com via RSS

Error. Page cannot be displayed. Please contact your service provider for more details. (14)



Related Posts


Subscribe to this Post

10 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.

  8. Julie Says:

    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 :)

  9. Safak Ozpinar Says:

    +”\” 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!

  10. furnizor mobila Says:

    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!