HTML Embedded PDF's & onload

后端 未结 8 1286
一生所求
一生所求 2020-12-24 06:35

I\'m embedding a PDF in a web page with the following html :-



        
                      
相关标签:
8条回答
  • 2020-12-24 07:09

    You are going to want something like jQuery's document.ready() function. For non-IE browsers, you can register a handler for the event DOMContentLoaded, and your handler function will be called after all the images and objects have been loaded. For IE, you have to continually check the document.readyState property, and wait for it to be "complete".

    If you are using jQuery, they've done the hard work for you, so all you have to do is:

    $(document).ready(function() {
        //take away the "loading" message here
    });
    

    If you don't want to use jquery, you'd have to do something like:

    addEventListener('DOMContentLoaded', function() { 
        //take away the "loading" message here
    });
    
    function waitForIE() {
    
        if (!document.all) return;
    
        if (document.readyState == "complete") {
            //take away the "loading" message here
        }
        else {
            setTimeout(waitForIE, 10);
        }
    }
    
    waitForIE();
    
    0 讨论(0)
  • 2020-12-24 07:10

    I don't know why everyone makes it so hard.

    <object data="yourfile.pdf" style="background: transparent url(AnimatedLoading.gif) no-repeat center;" type="application/pdf" />
    
    0 讨论(0)
  • 2020-12-24 07:10
    $(document).ready(function() {
       });
    

    would not work as this fires mostly on document.readyState == interactive rather than on document.readyState == complete.

    If you put a timer with this check (document.readyState == "complete") it would definitely work!

    0 讨论(0)
  • 2020-12-24 07:13

    Following code works.

    <div style="background: transparent url(loading.gif) no-repeat">
    <object height="1250px" width="100%" type="application/pdf" data="aaa.pdf">
    <param value="aaa.pdf" name="src"/>
    <param value="transparent" name="wmode"/>
    </object>
    </div>
    
    0 讨论(0)
  • 2020-12-24 07:15

    None of the recommendations are valid, because DOM is loaded before the PDF content is loaded. So DOM can't control ActiveX content

    0 讨论(0)
  • 2020-12-24 07:20

    "Content within a tag is displayed when an object is loading, but hasn't yet finished."

    So put your spinner in there and it should work out nicely for you. And you won't have to write any JavaScript.

    src: http://en.wikibooks.org/wiki/XHTML/XHTML_Objects

    0 讨论(0)
提交回复
热议问题