Marat Tanalin on web-development and IT [3]

  • Parens on creating objects with no arguments

    The following syntax is often used to create a programmatic object:

    new Example();

    Actually, if arguments are not passed to constructor at all, parentheses after the class name are unneeded:

    new Example;

    This is applicable at least to JavaScript, PHP, and C++.

  • Robert O’Callahan: “Full Hardware Acceleration”

    Microsoft marketing is making noises about IE9 having a monopoly on “full hardware acceleration”. They’re wrong; Firefox 4 has all the three levels of acceleration they describe.


    I’m pretty confident that our architecture will not cause us any performance disadvantages vs IE9. On the other hand, our architecture does let us deliver D3D acceleration for Windows XP users — which is still a very large market. (…) Our architecture also lets us deliver GL acceleration for Mac, X, and mobile devices, which is very important.


    BTW “full hardware acceleration” is a bogus phrase. All browser pick and choose how to use the GPU, and more use of the GPU isn’t necessarily better.

    Robert O’Callahan

  • Placing a Flash movie in arbitrary directory

    Complex Flash movies are often consist of several files: main swf file (movie itself), and dynamically-loaded movies, external ActionScript scripts, images, etc.

    By default, Flash Player searches all accompanying files, paths to which are specified in relative form inside movie, in the same directory (folder) that contains webpage that the movie is embedded to. However it’s often more convenient and rational to place Flash movie and all accompanying files into a separate directory.

    To keep movie working in such cases, it’s enough to supply the corresponding Flash object with the base parameter. Value of the parameter should contain path to directory that contains the Flash movie and other files needed for the movie:

    <param name="base" value="/dir/with/files/" />

    Detailed information on this and other parameters of Flash movies is available in Adobe’s online documentation.

  • Media streaming with JW Player (+)

    If in latest versions of JW Player — a popular Flash-based player of audio and video files and streams — playing audio stream spontaneously stops in several seconds after start, then just add the duration variable with -1 value to the flashvars parameter of Flash movie (which is JW Player itself).

  • How to disable compatibility view mode for site in IE8 (+)

    To prevent users from switching to compatibility-view mode when viewing your webpage in IE8 (this mode is often accidentally enabled by users — due to “good” placement of the corresponding button ), when IE8 operates almost identically to IE7 (e. g. does not support display: table), use the X-UA-Compatible meta element (or server response header of the same name) with IE=edge value.

  • HTML comment as data container (+)

    Regular HTML comment can be used as a container to store text data intended to be displayed dynamically with JavaScript.

    A comment is a separate DOM node, and its text content is available with the standard property of any DOM node — nodeValue, or with the data property of the comment as a DOMCharacterData object.

  • {overflow: hidden} and {position: relative} in IE

    In IE 6/7, blocks positioned absolutely (position: absolute) or relatively (position: relative) usually ignore overflow: hidden declaration of their container element, and go beyond the container’s bounds.

    This issue can be resolved by specifying relative positioning (position: relative) for the container itself:

    /* child element */
    #child {background: #ссс; position: relative; top: -25px; }

    /* its container */
    #parent {overflow: hidden; position: relative; height: 50px; }
    <div id="parent"><div id="child">example</div></div>
  • SWFObject 2.0

    A new version of SWFObject JavaScript-library has been released relatively unnoticed. The library is intended for handy and standards-compliant cross-browser embedding of Flash movies to webpages.

    At the same time, SWFObject 2.0 is a successor of the two similar libraries at once: previous version of SWFObject (1.5) and UFO. Their authors have combined their efforts to create a more perfect Flash-embedding mechanism represented by the new SWFObject 2.0, and they now recommend it as a replacement of their former solutions.

  • Link to the home page of a website

    Link to the home page of a website should look like this:

    <a href="/">…</a>

    …and in no way should point to a file, e. g.:

    • <a href="/index.htm">…</a>
    • <a href="/index.php">…</a>
    • <a href="/index.aspx">…</a>

    Otherwise, site will have two identical home pages — the one that is shown in browser’s location bar when user has typed-in the website’s domain name (, and the second one where user goes to by clicking “home”-page link placed on the site pages (