can'时出错;使用jquery单击添加事件时是否运行swf?

can'时出错;使用jquery单击添加事件时是否运行swf?,jquery,Jquery,我有一个示例代码: <a title="click" href="test.swf" class="game-in-link" style="background:#000;width:100%;height:450px;display:block;">CLICK ON PLAY</a> <div> <!-- <object width="100%" height="450"> <param name="movie" value=

我有一个示例代码:

<a title="click" href="test.swf" class="game-in-link" style="background:#000;width:100%;height:450px;display:block;">CLICK ON PLAY</a>
<div>
<!--
<object width="100%" height="450">
   <param name="movie" value="test.swf"></param>
   <param name="wmode" value="transparent"></param>
   <param name="allowFullScreen" value="true"></param>
   <param name="allowscriptaccess" value="always"></param>
   <embed src="test.swf" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="100%" height="450"></embed>
</object>
-->
</div>

和jquery:

// Get SWF file
jQuery("a.game-in-link").one('click', function () {
    var anchor = jQuery(this);
    anchor.html(anchor.html().replace('<div><!--', '').replace('--></div>', ''));
    anchor.removeAttr('href');
    return false;
});
//获取SWF文件
jQuery(“a.game-in-link”).one('click',function(){
var-anchor=jQuery(this);
html(anchor.html().replace(“”,”);
anchor.removeAttr('href');
返回false;
});
=>错误无法填写test.swf,如何获取带有结果的swf文件

<object width="100%" height="450">
   <param name="movie" value="test.swf"></param>
   <param name="wmode" value="transparent"></param>
   <param name="allowFullScreen" value="true"></param>
   <param name="allowscriptaccess" value="always"></param>
   <embed src="test.swf" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="100%" height="450"></embed>
</object>

您应该试试这个

<a title="click" href="test.swf" class="game-in-link" style="background:#000;width:100%;height:450px;display:block;">CLICK ON PLAY</a>
<div id="swfPlayer" style="display:none;">
<object width="100%" height="450">
   <param name="movie" value=""></param>
   <param name="wmode" value="transparent"></param>
   <param name="allowFullScreen" value="true"></param>
   <param name="allowscriptaccess" value="always"></param>
   <embed src="" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="100%" height="450"></embed>
</object>
</div>
这可能会起作用:

jQuery("a.game-in-link").one('click', function (e) {
    e.preventDefault();
    var anchor = jQuery(this).next(); //get next div
    var a = anchor.html().replace('<!--', '').replace('-->', '');
    anchor.html(a).prev().attr('href', '#'); //substitute html and a href
    return false;
});
jQuery(“a.game-in-link”).one('click',函数(e){
e、 预防默认值();
var anchor=jQuery(this).next();//获取下一个div
var a=anchor.html().replace(“”,”);
anchor.html(a.prev().attr('href','#');//替换html和a href
返回false;
});

+1我所做的唯一修改是将整个内容包装在一个包含元素中,并使jQuery选择器相对于单击的链接及其包含的父项,而不是使用绝对ID来查找嵌入的Flash。
jQuery("a.game-in-link").one('click', function (e) {
    e.preventDefault();
    var anchor = jQuery(this).next(); //get next div
    var a = anchor.html().replace('<!--', '').replace('-->', '');
    anchor.html(a).prev().attr('href', '#'); //substitute html and a href
    return false;
});