Important: Please read the Qt Code of Conduct -

Embedded object not loaded when "display:none" style property is added

  • Hi all,

    my application (on linux desktop for now) is based on Qt 4.8 and displays a web page using the Webview object. I also have an NPAPI plug-in to handle objects like

    <object type="myplygintype"></object>

    Everything works fine and my plug-in gets called to create such objects as expected until I add

    style="display: none"

    to the object tag, in which case it seems that the object is not loaded at all and the browser doesn't call my plug-in.

    At it is said "display:none hides an element, and it will not take up any space. The element will be hidden, and the page will be displayed as if the element is not there", therefore I would expect my plug-in to be called for the creation of the object. Is my understanding correct?
    Is there a bug or it is the expected behaviour?

    Thank you

  • I try this code in QT5.2:

    @<!DOCTYPE html>
    <meta charset="utf-8">
    var doc = document, s = ""+(new Date().getTime());
    '<object id="a1" width="400" height="40"'+
    ' classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'+
    ' codebase=",0,0,0">'+
    '<param name="SRC" value="'+s+'">'+
    '<embed src="'+s+'" width="400" height="40"></embed>'+

    }, 5000);

    worked perfectly equal in Firefox and Chrome.

  • Hi Guilherme, could you explain your example code? All I can see is that the display property is set to block after 5 seconds. My problem seems to be the browser does not load an object (or the plug in is not invoked) when display:none. How is your example related to this?

    Thank you,

  • My code need test with WebInspector, you will see that the plugins only carry after 5 seconds (use the WebInspector in QWebView/Chrome/Safari and Firebug in Firefox).

    far we have tested the plugins work the same way in GoogleChrome, Firefox, Safari and QWebView.

    Best you put an example to make it easier to understand the situation in which failure happens.

  • With some delay I managed to go back to this issue. To better explain my problem, I copied the example at:

    I added a print at the beginning of

    @QObject *CSVFactory::create(const QString &mimeType, const QUrl &url,
    const QStringList &argumentNames,
    const QStringList &argumentValues) const
    qDebug() << "CSVFactory::createm mimeType: " << mimeType;

    To be able to detect on console when the browser loads the plugin.

    My index.html looks like this:


    Embedded object:
    <object id = "plugin"
    width="100%" height="300"></object>
    <div id="msg1"></div>

    document.getElementById("msg1").textContent = "Display is set to block";
    }, 5000);

    when the example application is launched the print is not visible even though the embedded object of the correct mime type is in the HTML. Afer 5 seconds timeout, the javascript changes the display property to block and at that point the print appears on the console.

    This should prove that the plugin object is not loaded unless visible, which doesn't seem to be what w3c specifies, as display:none should only hide the object.

    I hope my question is now clearer and somebody will be able to answer it.

    Thank you!

Log in to reply