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 http://www.w3schools.com/jsref/prop_style_display.asp 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>
    <html>
    <head>
    <meta charset="utf-8">
    </head>
    <body>
    <script>
    var doc = document, s = "http://www.w3schools.com/html/bookmark.swf?"+(new Date().getTime());
    doc.write(
    '<object id="a1" width="400" height="40"'+
    ' classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'+
    ' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0">'+
    '<param name="SRC" value="'+s+'">'+
    '<embed src="'+s+'" width="400" height="40"></embed>'+
    '</object>'
    );

    setTimeout(function(){
    document.getElementById("a1").style.display="block";
    }, 5000);
    </script>
    </body>
    </html>@

    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,
    Sergio



  • 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:
    http://qt-project.org/doc/qt-4.8/webkit-simplewebplugin.html

    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:

    @<html>
    <head></head>
    <body>

    Embedded object:
    <object id = "plugin"
    style="display:none"
    type="text/csv;header=present;charset=utf8"
    data="qrc:/data/accounts.csv"
    width="100%" height="300"></object>
    </body>
    <div id="msg1"></div>

    [removed]
    setTimeout(function(){
    document.getElementById("msg1").textContent = "Display is set to block";
    document.getElementById("plugin").style.display="block";
    }, 5000);
    [removed]
    </html>@

    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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.