用JavaScript函数重新加载HTML元素 [英] Reloading an HTML element with a Javascript function

查看:111
本文介绍了用JavaScript函数重新加载HTML元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在DIV中嵌入了一个flash对象。现在我想在该div上方使用链接('a'标签),以便用户能够重新加载该闪存拨号程序,或者更具体地说,它包含的div标签(我无法以任何方式更改该闪存文件)。



我试过下面这个JS函数,但它不起作用(当点击'reload'链接时不重新加载div和内容。

 < div class =userProfile> 
< script type =text / javascript>
();
}
< / script>
< a href = javascript:refreshDialer()>重新加载< / a>
< div id =dialerDiv1>
< embed type =application / x-shockwave-flashwmode =opaque
src =http://dummysite.com
width =301
height =401
id =popUpSwf
name = popUpSwf
quality =high
border =none
allowcriptaccess =always
pluginspage =http://www.adobe.com/go/getflashplayer
scale = noscale
menu =false
flashvars =#/>
< / div>
< / div>

我在这里做错了什么?

感谢

解决方案

试试这个:

  function refreshDialer(){
// alert(In function);
var container = document.getElementById(dialerDiv1);
var content = container.innerHTML;
// alert(content);
container.innerHTML = content;
}

使用youtube链接进行操作作为示例。


I have a flash object embedded inside a DIV. Now I want to use a link('a' tag) above that div for the user to be able to reload that flash dialer, or more specifically the div tag it is contained in(I cannot change the flash file in any way).

I've tried using this JS function below, but it does not work(does not reload the div and contents when hitting the 'reload' link.

<div class="userProfile">
<script type="text/javascript">
     function refreshDialer(){
             document.getElementById("dialerDiv1").contentWindow.location.reload(true);
            }
</script>
<a href="javascript: refreshDialer()">Reload</a>
<div id="dialerDiv1">
    <embed type="application/x-shockwave-flash" wmode="opaque"                     
            src="http://dummysite.com"
            width="301"
            height="401"
            id="popUpSwf"
            name="popUpSwf"
            quality="high"
            border="none"
            allowscriptaccess="always"
                            pluginspage="http://www.adobe.com/go/getflashplayer"
            scale="noscale"
            menu="false"
            flashvars="#" />
</div>
</div>

What am I doing wrong here?

Thanks

解决方案

Try this:

function refreshDialer(){
   //alert("In function");
   var container = document.getElementById("dialerDiv1");
   var content = container.innerHTML;
   //alert(content);
   container.innerHTML= content;
}

In action using youtube link as example.

这篇关于用JavaScript函数重新加载HTML元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆