remove http-equiv="refresh" via javascript

306 views Asked by At

so I got a problem I`ve got a HTML Page which is generated by a programm (So not possibly to change it by hand). This got the meta

<meta http-equiv="refresh" content="4; URL=subst_001.htm">

Because of this the iframe in which I embed it, keeps reloading after 4 seconds which breaks my javascript code I would have normally used to display it. Any Ideas of removing it via Javascript, or any other way would be highly appreciated.

Have a nice day

DidnĀ“t found a solution on google so hoppefully somebody has a Idea

1

There are 1 answers

0
user3221512 On

This may work, although I have not tested this code. You may need to edit this code to make it work.

This approach will only work if the iFrame and the host page both on the same domain.

function removeMetaRefresh(){
  const theMetaTag = document.querySelector('meta[http-equiv="refresh"]');
  theMetaTag.remove();
}

const theFrame = document.querySelector('iframe');
theFrame.contentWindow.myFunction = removeMetaRefresh;
theFrame.contentWindow.myFunction();