我有一个带有Flash播放器的网站。
此代码为我提供了存储在player_codes.php中的flash播放器:
<script language="javascript" type="text/javascript" src="songs_related/flashmp3player/swfobject.js" ></script>
<!-- Div that contains player. -->
<div id="player">
<h1>No flash player!</h1>
<p>It looks like you don't have flash player installed. <a href="http://www.macromedia.com/go/getflashplayer" >Click here</a> to go to Macromedia download page.</p>
</div>
<!-- Script that embeds player. -->
<script language="javascript" type="text/javascript">
var so = new SWFObject("songs_related/flashmp3player/flashmp3player.swf", "player", "290", "247", "9"); // Location of swf file. You can change player width and height here (using pixels or percents).
so.addParam("quality", "high");
so.addVariable("content_path","songs_related/uploads"); // Location of a folder with mp3 files (relative to php script).
so.addVariable("color_path","songs_related/flashmp3player/default.xml"); // Location of xml file with color settings.
so.addVariable("script_path","songs_related/flashmp3player/flashmp3player.php");
// Location of php script.
so.write("player");
</script>
这就是我包含播放器后端的方式
<div id="main_music_player_for_the_site">
<?php include_once('player_codes.php'); ?>
</div>
如果你转到此链接here并按下列表中任何一首歌的播放,则会发生以下情况:
但是当第3步发生时它会刷新! 并卡住
它本身不应该在我的localhost中刷新。
这是我的JS做的工作(在我得到第2步的回复后调用)
function callBackForLoadSong(data)
{
//alert(data);
if(data == "failed")
{
alert("Song requres you to login. Its easy to create an account! We will take you to the login page after you press ok");
window.location.replace(REDIRECT);
}
else
{
//alert("s");
$("#main_music_player_for_the_site").text("refreshing player...");
$("#main_music_player_for_the_site").load("player_codes.php");
}
}
困扰我的主要原因是为什么页面会刷新?而且卡住了
答案 0 :(得分:0)
每个播放按钮都有相同的HREF。看起来你的onClick事件会加载歌曲吗?
你应该:
<a href="javascript:void(0)" onclick="loadSong('849','http://bedupako.com/songs.php');return false;">play</a>
而不是:
<a href="songs_related/create_play_list.php?single=0&songid=849&url=http://bedupako.com/songs.php" onclick="loadSong('849','http://bedupako.com/songs.php');return false;">play</a>
现在,您告诉javascript使用onClick事件加载您的歌曲,并告诉浏览器使用HREF转到其他URL。 javascript:void(0)将阻止浏览器执行HREF。
答案 1 :(得分:0)
实际问题在我执行我的回复后,我的返回值为false!
以下是更正的JS:
function callBackForLoadSong(data)
{
//alert(data);
if(data == "failed")
{
alert("Song requres you to login. Its easy to create an account! We will take you to the login page after you press ok");
window.location.replace(REDIRECT);
}
else
{
//alert("s");
$("#main_music_player_for_the_site").text("refreshing player...");
$("#main_music_player_for_the_site").load("player_codes.php");
}
return false;
}
所以返回假;必须在函数中指定