html - Change 2 strings on load with javascript -
i try replace 2 parts of string in lot of pages on page load.
in case, replace:
<iframe width="890" height="514" src="https://www.youtube.com/embed/
with string and
?enablejsapi=1" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
with one. tried use
<script type="text/javascript"> window.onload = clear; function clear() { document.body.innerhtml = document.body.innerhtml.replace(/xxx/g, 'yyy'); } </script>
but did not work.
it needs done on page load. idea? thank you!
edit:
what try do, split youtube embed in div. part before unique youtube id needs replaced , part after id needs replaced. complete link like:
<iframe width="890" height="514" src="https://www.youtube.com/embed/xxxxxxxx?enablejsapi=1" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
the part before xxxxxxxx , part after xxxxxxxx need changed on load more complete code including div's , classes.
thank you!
Comments
Post a Comment