SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict EarlyOut's Avatar
    Join Date
    Mar 2011
    Sector R
    0 Post(s)
    0 Thread(s)

    IE9 and swffit.js

    Full disclosure: I don't know Javascript. Yes, I should learn it, but at the moment I just have a specific problem I'm trying to solve, so I'm hoping someone with the skills and/or tools to hunt down the source of it will take pity on me.

    I'm using Miller Medeiros' swffit.js script (swffit - Smart Flash Resize Script - 100% Width and 100% Height) to resize a Flash presentation. It's misbehaving slightly in IE9, and while I can overcome that with an "X-UA-Compatible" meta tag, I'd rather not introduce hacks to accommodate a current browser.

    For context, here's where everything ends up: Vertical Scrollbar. Click the first thumbnail. Use the little drag handle at lower right to resize the window. This works perfectly in FF3, FF4, Chrome, IE7, and IE8. But in IE9, I end up with a vertical scrollbar in the window.

    In that context, there are a lot of "actors" involved, including the Highslide JS expander and the JW Player. But we can eliminate those red herrings. Here's a very stripped-down example, one that involves only swfobject.js, swffit.js, a few lines of HTML, and a boring little SWF file: SWF Fit Minimal. Change the browser window size, and you'll see that in IE9, the vertical scrollbar never goes away, unlike the result in any other browser. For this example, I'm using the swffit.js source code rather than the packed version, to make tinkering easier. The last non-beta version of swffit.js, by the way, has exactly the same problem.

    My guess is that there's something different about the way IE9 reports the viewport size, or about the way it responds to the resized Flash object, but I don't know how to track down those differences.

    I ran this by Miller, and his suggested solution doesn't seem to have any effect: Another minor IE9 issue - SWFFit | Google Groups. I've tried tinkering with that chunk of the code, but with no luck (and it would be just luck, not skill, if I stumbled on the solution).

    In that thread, and in several others (Discussions - SWFFit | Google Groups), he's made it fairly clear that a new version of swffit.js is not really on the horizon. Who can blame him? Paying clients have to come first, after all.

    Anyone out there who can fix the script?


  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Christchurch, New Zealand
    104 Post(s)
    4 Thread(s)
    For anyone else who's looking into this, it appears that swiffit performs browser sniffing:

    IE = /msie/.test(AGENT) && !win.opera,
    These are the parts of the code that are affected by such browser sniffing.

    if(IE){ swfobject.addLoadEvent(initFit); } //fix conflict with swfaddress 2.3 and IE8 (in some browser modes)
    st += (IE)? '; overflow:hidden' : ''; //fix IE8
    //fix window innerSize difference when scrollbar is visible
    iw -= (!IE && ih <= _mh)? 18 : 0;
    ih -= (!IE && iw <= _mw)? 18 : 0;
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Sydney, NSW, Australia
    25 Post(s)
    1 Thread(s)
    Quote Originally Posted by paul_wilkins View Post
    For anyone else who's looking into this, it appears that swiffit performs browser sniffing:
    Yet another example of why browser sniffing is not a good idea - it usually breaks when a new version of a browser comes out. Also that code is breaking the page just the same for anyone using any other browser where the useragent is set to identify the browser as IE rather than what it really is - as you can do in all the popular browsers.
    Stephen J Chapman, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts