javascript - Safari open and close img MIME type multipart / x-mixed-replace streaming on demand -


testing mobile safari web application, find have image in tag img src changes dynamically. src reference url generates streaming mjpeg mime type multipart / x-mixed-replace. changing src notice browser not close connection server, server continues process if asking follow streaming client , should not , not exist in dom. try use methods remove , empty jquery api , assign src null or empty string without getting them behave way classic browsers. possible achieve this? thanks

in case still looking answer, had same problem in older version of chrome (not tested safari may same solution) , thing worked me calling window.stop(). stop connection in page if there things don't want stop, can put image inside iframe , call stop on iframe window.

  • add iframe:

    <iframe id="image" src="" seamless="seamless"><p>your browser not support iframes.</p></iframe> 
  • add image:

    var frame = document.getelementbyid('image'); var img = document.createelement("img"); img.src = myimgsource; frame.contentdocument.body.appendchild(img); 
  • and when want change img src, call stopload function on iframe before:

    function stopload(frame) {    var cw = frame.contentwindow;    if (cw.stop) {       cw.stop();    } else {       cw = frame.contentdocument;       if (cw.execcommand) {          cw.execcommand("stop", false);       }    } } 

you may need add style iframe , content image appears if directly in main window.


Comments