欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

javascript firefox 自動(dòng)加載iframe 自動(dòng)調(diào)整高寬示例

 更新時(shí)間:2013年08月27日 15:44:07   作者:  
iframe 自動(dòng)獲取onload高寬以及iframe 自動(dòng)加載,具體實(shí)現(xiàn)如下,感興趣的朋友可以參考下
iframe 自動(dòng)獲取onload高寬
復(fù)制代碼 代碼如下:

function AutoResize(iframe)
{
//firefox
if(iframe.contentWindow)
{
iframe.height = iframe.contentWindow.document.documentElement.scrollHeight;
iframe.width = iframe.contentWindow.document.documentElement.scrollWidth;

}
//IE
else if(iframe.contentDocument) {

iframe.height = iframe.contentDocument.width;
iframe.width = iframe.contentDocument.height;
}
}

iframe 自動(dòng)加載:
復(fù)制代碼 代碼如下:

var tdObj = document.getElementById('ifrtd');
tdObj.innerHTML = ' QQ動(dòng)態(tài)加載中 ... ';

var iframe = document.createElement("iframe");
iframe.src = 'http://www.zbphp.com/';

if (iframe.attachEvent){

//iframe.attachEvent("onload",AutoResize.call(iframe)); #報(bào)錯(cuò)
iframe.attachEvent("onload", function(){
AutoResize(iframe);
});
} else {

//iframe.onload = AutoResize.call(iframe);#報(bào)錯(cuò)不支持
iframe.onload = function(){
AutoResize(iframe);
};
}

tdObj.innerHTML = '';
tdObj.appendChild(iframe);

其實(shí)那個(gè)iframe.onload這里想寫(xiě)成iframe.onload = AutoResize.call(iframe);很遺憾,報(bào)錯(cuò),不支持。

一直不知道javascript 如何進(jìn)行函數(shù)調(diào)用。比如遇到 iframe.onload = function(){} 調(diào)用函數(shù)且有參數(shù)的時(shí)候,這樣的情況只能這樣寫(xiě),而不能像其他程序那樣直接傳參。

以前看過(guò)有 apply() call(),但試過(guò)都是不支持的。為什么?

相關(guān)文章

最新評(píng)論