Changing data content on an Object Tag in HTML

前端 未结 14 2185
抹茶落季
抹茶落季 2020-11-29 08:06

I have an HTML page which contains an Object tag to host an embedded HTML page.



        
      
      
      
14条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-29 09:04

    The above solutions did not work properly in Firefox, the Object tag doesn't refresh for some reason. My object tags show SVG images.

    My working solution for this was to replace the complete Object node with a clone:

    var object = document.getElementById(objectID);
    object.setAttribute('data', newData);
    
    var clone = object.cloneNode(true);
    var parent = object.parentNode;
    
    parent.removeChild(object );
    parent.appendChild(clone );
    

提交回复
热议问题