HTML Embedded PDF's & onload

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

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



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

    I'm loading the PDF with jQuery ajax into browser cache. Then I create embedded element with data already in browser cache.

    
    var url = "http://example.com/my.pdf";
    // show spinner
    $.mobile.showPageLoadingMsg('b', note, false);
    $.ajax({
        url: url,
        cache: true,
        mimeType: 'application/pdf',
        success: function () {
            // display cached data
            $(scroller).append('<embed type="application/pdf" src="' + url + '" />');
            // hide spinner
            $.mobile.hidePageLoadingMsg();
        }
    });
    

    You have to set your http headers correctly as well.

    
    HttpContext.Response.Expires = 1;
    HttpContext.Response.Cache.SetNoServerCaching();
    HttpContext.Response.Cache.SetAllowResponseInBrowserHistory(false);
    HttpContext.Response.CacheControl = "Private";
    
    0 讨论(0)
  • 2020-12-24 07:32
    <embed onload='alert("I should be called")'></embed>
    
    0 讨论(0)
提交回复
热议问题