且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

用JavaScript函数重新加载HTML元素

更新时间:2023-12-05 12:59:22

试试这个:

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

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


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 *** link as example.