我正在尝试在新窗口中打开可点击链接,当我点击Flash播放器(jwplayer 5)时,这里是代码:
<head>
<script type="text/javascript">
function openwindow()
{
window.open("http://www.example.com","mywindow","menubar=1,resizable=1,scrollbars=1,width=350,height=250");
}
</script>
</head>
<body>
<a href="javascript: openwindow();">
<center><div id="mediaplayer">
<script type="text/javascript" src="player.js"></script>
<script type="text/javascript">
jwplayer("mediaplayer").setup({
flashplayer: "player.swf",
provider:'http',
file: "file.mp4",
screencolor: "000000",
width: "875",
height: "480",
plugins: {
'timeslidertooltipplugin-3': {}
}
});
</script>
</div></center>
</a>
</body>
这适用于Firefox,但不适用于Chrome,在Firefox中我点击播放器后新窗口打开正常但在Chrome中我点击播放器时没有打开但是如果我点击播放器的外部它是开口。
知道为什么它不起作用吗?
提前致谢
答案 0 :(得分:1)
我建议不要使用任何内联javascript。你可以替换这行:
<a href="javascript: openwindow()">
使用:
<a href="#" id="linkId">
并将该功能添加到您的script
标记中。所以它最终看起来像这样:
<a href="#" id="linkId">
<center>
<div id="mediaplayer">
<script type="text/javascript" src="player.js"></script>
</div>
</center>
</a>
<script type="text/javascript">
jwplayer("mediaplayer").setup({
flashplayer: "player.swf",
provider:'http',
file: "file.mp4",
screencolor: "000000",
width: "875",
height: "480",
plugins: {
'timeslidertooltipplugin-3': {}
}
});
document.getElementById("linkId").onclick = function(){
window.open("http://www.example.com","mywindow","menubar=1,resizable=1,scrollbars=1,width=350,height=250");
}
</script>