在JavaScript中设置超时
Firefox总是加载动态图像,但是IE只是显示图像而没有任何动态动作。我需要做些什么改变?
IE查看源代码中的JavaScript代码:
<script type=”text/javascript” <!--/*--><![CDATA[/*><!--*/
if (document.getElementById("safeForm1d3").submitted.value == "false") {
document.getElementById("safeForm1d3").submitted.value = "true";
setTimeout('document.getElementById("safeForm1d3").submit()', 100);
}else{
document.getElementById("toHide").style.display="none";
}/*-->]]>*/
</script>
我正在使用Wicket框架,所以真正的Java代码是:
static private class SafeSubmitBehaviour extends AbstractBehavior{ public void onRendered( Component component ) {
super.onRendered( component );
StringBuffer buffer = new StringBuffer(200);
buffer.append("<script type=\"text/javascript\" ><!--/*--><![CDATA[/*><!--*/\n");
buffer.append("if (document.getElementById(\"").append(component.getMarkupId()).append("\").submitted.value == \"false\") {\n");
buffer.append("document.getElementById(\"").append(component.getMarkupId()).append("\").submitted.value = \"true\";\n");
buffer.append("setTimeout('document.getElementById(\"").append(component.getMarkupId()).append("\").submit()', 100);\n}else{\n");
buffer.append("document.getElementById(\"toHide\").style.display=\"none\";\n}/*-->]]>*/</script>");
component.getResponse().write(buffer);
}
}
加载我的动态图像的html页面是:
<div id="toHide" class="pb-text-align-center"> <img style="display: inline" src="img/load.gif" />
<form wicket:id="safeForm" class="clearfix">
<input type="hidden" wicket:id="submitted" value="false" />
</form>
</div>
回答:
解决了我的问题。可能对其他人有用:
回答:
HTML源代码:
<SCRIPT type="text/javascript"> var $ = jQuery.noConflict();
document.getElementById('toHide').style.display ="";
$('#toHide').doTimeout(1000, function() {
$('#toHide').find('#safeForm34').submit();
document.getElementById('myAnimatedImage').src = "../../img/load.gif";
});
</SCRIPT>
HTML:
<div id="toHide" class="pb-text-align-center"> <img src="img/load.gif" id='myAnimatedImage' style="margin-left: auto; margin-right: auto;"/>
<form wicket:id="safeForm" class="clearfix" />
</div>
以上是 在JavaScript中设置超时 的全部内容, 来源链接: utcz.com/qa/415444.html