IE8 dashboard that blocks script file loading in response to a jQuery AJAX request

I have an html / javascript interface that uses a JQuery AJAX query to send XML containing user-entered form data to a backend application, which in turn creates a PDF from this information. The interface receives a UUID response, which it then uses in the boot URL to download the generated PDF file.

This works great in Firefox and Safari, but is blocked by Internet Explorer 8's protection against downloadable scripts. Reporting that IE8 to download a file through the generated dashboard forcibly reloads the page, which frees all the user content entered.

One onMouseUp event in the button-esque element triggers the generation of the sent XML, sends the XML, receives its response, and then initiates the download by setting the URL in the window.location object. Dividing this download into another button (with which you generate and send xml and select the UUID, and the other only initiates the download using the URL made from the UUID) bypasses the information panel, but destroys the simplicity and intuitiveness of the interface.

Here are the relevant javascript functions:

function sendXml()
{
    var documentXml = generateDocumentXml();
    var percentEncodedDocumentXml = escape(DocumentXml);
    var url = "generate?document=" + percentEncodedDocumentXml;
    $.ajax({
        url: url,
        type: "GET",
        dataType: "xml",
        success: function (xml)
        {
            var uuid = $(xml).find('uuid').text();
            getPdf(uuid);
        },
        error: function (xhr)
        {
            alert("There was an error creating your PDF template");
        }
    });
}

function getPdf(uuid)
{
    var url = "generate?get-pdf=" + uuid;
    window.location = url;
}

, . , , . , , " ..." , .

+3
1

, , (mouseover) URL ( PDF ).

:

iframe ( )

window.open(url,'nameAttributeOfTheIframe') 

... PDF . , , , ( -) , iframe .

- PDF , ( ), iframe, , .

<iframe name="nameAttributeOfTheIframe" style="display:none"></iframe>
<input type="button" value="click here"  onclick="f1()"/>
<input value="default value">
<script type="text/javascript">
<!--
function f1()
{
   //simulate delayed download
   setTimeout(f2,1000)     
}

function f2()
{
  window.open('http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf','nameAttributeOfTheIframe');      
}

document.getElementsByTagName('input')[1].value='this is modified value, should remain';

//-->
</script>
+2

Source: https://habr.com/ru/post/1777591/


All Articles