最簡單的說明問題:::::::::::
function exterfun(img1,img2){
var i;
function corefun(i){
$(img1).attr("onload","corecorefun(i)");
}
function corecorefun(i){
}
}
可是,系統提醒,無法找到 corecorefun 這個函式。
onload里面怎么呼叫 corecorefun,怎么傳遞引數 i
謝謝。
背景如下:
我做了一個img的處理。
回圈處理5次。img2list 是 5個成員的list
最核心的是 corefun函式,傳入當前處理的idx。就在img2list取出對應的成員。
function exterfun(img1,img2list){
var div = document.createElement("div");
document.body.appendChild(div);
var idx=0;
corefun(0);
function corefun(i){
$(div).html("");
$(div).append(img1);
$(div).append(img2list[i]);
// 處理 像素 img1 img2[i]
//
。。耗時間處理。。
//
// 現在需要加入 onload 不然img空白。
idx++;
if(idx>5){
// return job.
}else{
corefun(idx);
}
}
}
代碼的問題是,沒有在 onload 中處理img1, 所以很可能img1 是空白的。
所以需要在img的 onload 里面出來資料。
為此,我再加了一個 corecorefun函式。放到onload里面。
function exterfun(img1,img2){
var div = document.createElement("div");
document.body.appendChild(div);
var idx=0;
corefun(0);
function corefun(i){
$(div).html("");
$(div).append(img1);
$(div).append(img2);
$(img1).attr("onload","corecorefun(i)");
}
function corecorefun(i){
// 處理 像素 img1 img12
//
。。耗時間處理。。
//
idx++;
if(idx>5){
// return job.
}else{
corefun(idx);
}
}
}
可是,系統提醒,無法找到 corecorefun 這個函式。
沒有定義。請教一下,一個function下面的兩個子函式,其中一個子函式的onload怎么呼叫另外一個子函式?
謝謝。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/268065.html
標籤:JavaScript
下一篇:slice引數中負數用法
