执行java脚本函数时出现问题 [英] Problem in executing java script function
问题描述
你好
我有一个iFrame,我想设置它的高度取决于它的内容。我已经编写了代码并且它工作正常,但它会在我的项目的一些运行中执行。
例如,如果我运行我的项目,iFrame有默认高度,当我按(ctrl + F5)刷新页面时,该功能将被执行并且工作正常,因此iFrame高度将根据内容自动调整。
或者我应该用FireBug插件运行项目并调试它以正常工作。
我的功能优先级有误吗?
我尝试了什么:
我的hF中的iFrame:
Hello
I have an iFrame that I want to set it's height depends on it's content. I have wrote the code and it works fine, but it it will be executed in some runs of my project.
for example if I run my project, the iFrame has the default height, when I refresh the page by pressing (ctrl + F5) the function will be executed and works fine, so the iFrame height will automatically get adjusted based on content.
or I should run the project with FireBug plugin and debug it to works fine.
Do I have some mistake in my function priority?
What I have tried:
my iFrame in my html:
<iframe src="..." onLoad="ResizeIFrame(this);"></iframe>
在我的javascript中:
in my javascript :
function ResizeIFrame(obj) {
obj.height = obj.contentWindow.document.body.scrollHeight + 'px';
}
在此先感谢
最好的问候
Thanks in Advance
With best Regards
推荐答案
我找到了解决方案:
我已将代码放在document.ready中,如下所示:
I have found the solution:
I have placed the code, in document.ready as in below:
( document )。ready( function ( ){
setInterval( function (){
parent。
(document).ready(function(){ setInterval(function(){ parent.
( iframe)。height(
("iframe").height(
这篇关于执行java脚本函数时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!