Is there a cross-browser standard on-load event for HTML's “object” tag?

前端 未结 3 1423
南方客
南方客 2020-12-05 13:34

I am aware that IE supports the onreadystatechange attribute on the object tag, but this doesn\'t seem to be a standard way thus all other browsers

3条回答
  •  执笔经年
    2020-12-05 14:20

    So you want to trigger an event after the [PDF] object is loaded?
    If so, this might help you:

    http://www.webdeveloper.com/forum/showthread.php?t=160792

    ----- EDITED [19/10/2011] -----

    If you load the PDF inside an iframe, it will work.

    Check this: http://sykari.net/stuff/iframe

    The script will alert only after the PDF is completely loaded.
    (Tested with FF7 + Win7).

    ----- EDITED [20/10/2011] -----

    Using JQuery: http://jsfiddle.net/fcABz

    To be sure it is working i have added a 36 pages PDF file to the iframe, so you can watch the progress bar (at least in FF7 there is one, not sure about Chrome) going up, and after it is fully loaded, you will see an alert.

    Why? Because the .load method from JQuery will wait until all subelements inside the iframe are loaded.

    The load event is sent to an element when it and all sub-elements have been completely loaded. This event can be sent to any element associated with a URL: images, scripts, frames, iframes, and the window object.

    If you want to try more then once, clear the cache.
    Or change the PDF to a bigger one, like this http://pubs.usgs.gov/tei/532/report.pdf (90 pages).

提交回复
热议问题