JS页面iframe播放器点击打开关闭

Js 2019-10-25 12:46:26 评论

HTML代码

<div class="sider" id="bdzz">

[bofang]http://tv.cctv.com/2019/10/24/VIDEfGMt5OWGVdgEPEO9Xi31191024.shtml[/bofang]


</div>

JS代码

<script>
var nr = document.getElementById("bdzz");
nr.innerHTML = nr.innerHTML.replace(/\[bofang](.*?)\[\/bofang]/g,'<button><a href="#" onclick="kai();">打开播放</a></button><button><a href="#" onclick="guan();">关闭播放</a></button><br><iframe style="display:none;" frameborder="0" scrolling="no" width="90%" src="https://api.6uzi.com/?url=$1"/>');

function kai(){
var nr = document.getElementById("bdzz");
nr.innerHTML = nr.innerHTML.replace(/<iframe style="display:none;"/g,'<iframe style="display:inline;"');
};
function guan(){
var nr = document.getElementById("bdzz");
nr.innerHTML = nr.innerHTML.replace(/<iframe style="display:inline;"/g,'<iframe style="display:none;"');
};
</script>

评论

说点什么吧
  • 全部评论(0
    还没有评论,快来抢沙发吧!