在新窗口中打开对象

时间:2014-02-18 13:44:24

标签: javascript html

当用户点击链接时,我想在新窗口中打开SoundCloud播放器。以下是一个例子:

<object height="220" width="220"><param name="movie" value="https://player.soundcloud.com/player.swf?url=https%3A//api.soundcloud.com/tracks/124173519&amp;color=ff5500&amp;auto_play=false&amp;player_type=artwork"></param><param name="allowscriptaccess" value="always"></param><embed allowscriptaccess="always" width="220" height="220" src="https://player.soundcloud.com/player.swf?url=https%3A//api.soundcloud.com/tracks/124173519&amp;color=ff5500&amp;auto_play=false&amp;player_type=artwork" type="application/x-shockwave-flash"></embed></object>

我尝试了各种技巧,但无济于事。如果用户可以指出我正确的方向,那将非常感激。

2 个答案:

答案 0 :(得分:1)

创建类似于:<a href='javascript:window.open("page.html")' target="_blank" >link</a>的内容,其中包含“page.html”中的<object ../>标记。

答案 1 :(得分:0)

如果您可以使用完整的html动态生成对象,则可以使用javascript:

window.open(URL,name,specs,replace)

服务器端脚本示例:

//playsound.php

<html>
<head>
  .....
</head>
<body>
 ......
<object height="220" width="220"><param name="movie" value="https://player.soundcloud.com/player.swf?url=https%3A//api.soundcloud.com/tracks/124173519&amp;color=ff5500&amp;auto_play=false&amp;player_type=artwork"></param><param name="allowscriptaccess" value="always"></param><embed allowscriptaccess="always" width="220" height="220" src="https://player.soundcloud.com/player.swf?url=https%3A//api.soundcloud.com/tracks/124173519&amp;color=ff5500&amp;auto_play=false&amp;player_type=artwork" type="application/x-shockwave-flash"></embed></object>
</body>
</html>

因此,如果用户点击主窗口中的链接,则会弹出另一个窗口来播放媒体。我希望这有帮助