ich wie ein Skript haben unterwas bedeutet das Javascript bedeuten
qq.UploadHandlerForm = function(o){
this._options = {
action: '/upload',
onComplete: function(id, fileName, response){}
};
qq.extend(this._options, o);
this._inputs = {};
};
qq.UploadHandlerForm.prototype = {
add: function(fileInput){
fileInput.setAttribute('name', 'qqfile');
var id = 'qq-upload-handler-iframe' + qq.getUniqueId();
this._inputs[id] = fileInput;
// remove file input from DOM
if (fileInput.parentNode){
qq.remove(fileInput);
}
return id;
},
upload: function(id, params){
var input = this._inputs[id];
if (!input){
throw new Error('file with passed id was not added, or already uploaded or cancelled');
}
var fileName = this.getName(id);
var iframe = this._createIframe(id);
var form = this._createForm(iframe, params);
form.appendChild(input);
var self = this;
this._attachLoadEvent(iframe, function(){
self._options.onComplete(id, fileName, self._getIframeContentJSON(iframe));
delete self._inputs[id];
setTimeout(function(){
qq.remove(iframe);
}, 1);
});
form.submit();
qq.remove(form);
return id;
},
cancel: function(id){
if (id in this._inputs){
delete this._inputs[id];
}
var iframe = document.getElementById(id);
if (iframe){
iframe.setAttribute('src', 'javascript:false;');
qq.remove(iframe);
}
},
getName: function(id){
// get input value and remove path to normalize
return this._inputs[id].value.replace(/.*(\/|\\)/, "");
},
_attachLoadEvent: function(iframe, callback){
qq.attach(iframe, 'load', function(){
if (!iframe.parentNode){
return;
}
if (iframe.contentDocument &&
iframe.contentDocument.body &&
iframe.contentDocument.body.innerHTML == "false"){
return;
}
callback();
});
},
_createIframe: function(id){
var iframe = qq.toElement('<iframe src="javascript:false;" name="' + id + '" />');
iframe.setAttribute('id', id);
iframe.style.display = 'none';
document.body.appendChild(iframe);
return iframe;
},
_createForm: function(iframe, params){
var form = qq.toElement('<form method="post" enctype="multipart/form-data"></form>');
var queryString = '';
for (var key in params){
queryString += "/"+ encodeURIComponent(params[key]);
}
form.setAttribute('action', this._options.action + queryString);
form.setAttribute('target', iframe.name);
form.style.display = 'none';
document.body.appendChild(form);
return form;
}
};
Ich möchte wissen, was die „_“ für verwendet wird, und was „_createIframe: function (id) {}“ genannt ? Und was heißt "getName: function (id)"?
Zweitens möchte ich den getName innerhalb der "_createForm: Funktion (iframe, params) {}" verwenden. Wie kann ich es tun? Ich habe versucht, so etwas wie
_createForm: function(id,iframe, params){var fn= this.getName(id)}
bekam aber einen Fehler
EDIT: Hinzufügen von Informationen, die als Antwort gepostet.
Wenn ich
_createForm: function(iframe, params){
var fname = this.getName(id);
}
Ich habe Fehler "id ist nicht definiert". Dann versuche ich
_createForm: function(id, iframe, params){
var fname = this.getName(id);
}
Ich habe Fehler „this._input [...]. Wert ist null oder kein Objekt“
Haben Sie nie eine befriedigende Antwort auf alle Ihre Fragen erhalten? –
Was * ist * der Fehler? –
Jetzt verstehe ich Ihre Frage El Ronnoco, nur die alten Antworten angekreuzt –