Quantcast
Channel: Internet Explorer Web Development forum
Viewing all articles
Browse latest Browse all 3527

mssaveblob in ie 11 not working consistently

$
0
0

I have taken the sample code on MSDN and adapted it slightly for my purpose ( my code below). When I execute the code in IE 11 on my Windows 8.1 box (IE 11, v11.0.9600.17905), it works sometimes (i get the prompt to save, and my file appears in DOWNLOADS). However without changing ANYTHING at all, I run it again and it gets on error (the mssaveblob returns TRUE), however, no save occurs and the code completes. On another box running Windows 7 with IE 11 (v11.0.9600.17959), it never succeeds. Debugger shows me that everything is working and no FALSE returns in anything. Just, no file. I am at wits end.

<!DOCTYPE html>
<html>

<head>
  <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Passage #1 Essay</title>
</head>

<body>
  <h1>Passage #1 Essay</h1>
  <div>
<br><br><br><center>User ID</center>
    <br><center><input type="text" id="userIDtext" name="username"></center>
<br><center>THIS IS WHERE WE PUT THE PASSAGE #1 ESSAY QUESTION!</center>
    <br><center><label>Enter your answer in the box below:</label><br></center>
    <br><center><textarea id = "fileDisplayArea"
                  rows = "15"
                  cols = "100"
                  wrap = "hard"
                  contenteditable="true"></textarea></center>
  </div>  
  <p>
      <br><center><button type=button style="width:270px;height:40px" onclick="submitValue();" id='btnSubmit'>Submit</button></center>
  </p>

  <script>
    function requiredFeaturesSupported() {
      return ( BlobConstructor() && msSaveOrOpenBlobSupported() );
    }
    
    function BlobConstructor() {
      if (!window.Blob) {
        document.getElementsByTagName('body')[0].innerHTML = "<h1>The Blob constructor is not supported - upgrade your browser and try again.</h1>";
        return false;
      } // if
      
      return true;
    } // BlobConstructor
    
    function msSaveOrOpenBlobSupported() {
      if (!window.navigator.msSaveOrOpenBlob) { // If msSaveOrOpenBlob() is supported, then so is msSaveBlob().
        document.getElementsByTagName('body')[0].innerHTML = "<h1>The msSaveOrOpenBlob API is not supported - try upgrading your version of IE to the latest version.</h1>";            
        return false;
      } // if
      
      return true;
    } // msSaveOrOpenBlobSupported
    function submitValue() {
      if (requiredFeaturesSupported()) {
        var uservalue = document.getElementById("userIDtext").value;
        var essayAnswer = document.getElementById("fileDisplayArea").value;
        var blobObject = new Blob([uservalue + " = " + essayAnswer]);
      
        window.navigator.msSaveBlob(blobObject, 'Passage1_EssayAnswer.txt');
        window.location.assign(href="EndPage.html");
        }
    }
  </script>
</body>

</html>

html {
  font-family: Helvetica, Arial, sans-serif;
  font-size: 100%;
  background: lightblue;
  color: white;
  }

div {
  font-size: 100%;
  
  }

div#div3 {
  font-size: xx-large;
  color: white;
    }

form#form1{
    font-size: 100%;
  }

form#form3{
    font-size: medium;
  }

form#formL{
    font-size: 250%;
  }

a{
    color: black;
}
  
div#page-wrapper {
  width: 800px;
  background: #FFF;
  padding: 1em;
  margin: 1em auto;
  min-height: 300px;
  border-
  box-shadow: 0 2px 10px rgba(0,0,0,0.8);
  color: black;
  }

h1 {
margin-
  }
p {
  color: black
  }
h2 {
margin-top: 33;
  }

#fileDisplayArea {
  margin-top: 2em;
  width: 100%;
  overflow-x: auto;
  }


Viewing all articles
Browse latest Browse all 3527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>