Ah, no, everything's clear
. In your function call you pass three parameters but you only use the first one. You could use a variadric function in which all parameters are in the arguments array. So the function has to look like this:
Code:
function setLgImg(){
var imagepath=arguments[0];
var imageW=arguments[1]+"px"; //firefox is not interested in css values without the definition of its type ("px") - you know what I mean^^
var imageH=arguments[2]+"px";
oldHTML = document.getElementById('loadarea').innerHTML;
imageHTML = '<img src="'+imagepath+'" style="border: 1px solid #c00000\;" />'
imageHTML = '<img src="'+imagepath+'" style="border:1px solid #000000;width:'+imageW+';height:'+imageH+';" />'
document.getElementById('loadarea').innerHTML = imageHTML;
}
I think you are new to JS and for your project you need a class but - don't worry - JS classes are for children
. The problem is that your variables exist only in the function itself; not longer.
Code:
function ClassName() {
// global class variables defined here for further access in all member functions
// attention: this.functionname defines a public function. without this. is private. public functions can access on private functions and attributes but not the other way around.
var imageHTML;
var oldHTML;
var newHTML;
this.setLgImg = function() {
var imagepath=arguments[0];
var imageW=arguments[1]+"px"; //firefox is not interested in css values without the definition of its type ("px") - you know what I mean^^
var imageH=arguments[2]+"px";
oldHTML = document.getElementById('loadarea').innerHTML;
imageHTML = '<img src="'+imagepath+'" style="border: 1px solid #c00000\;" />'
imageHTML = '<img src="'+imagepath+'" style="border:1px solid #000000;width:'+imageW+';height:'+imageH+';" />'
document.getElementById('loadarea').innerHTML = imageHTML;
};
this.clearLgImg = function() {
imageHTML.value =''; return false;
};
this.changeText = function(evt){
oldHTML = document.getElementById('caption').innerHTML;
newHTML = "<p><span style='color:#c00000\;'>" + evt + "</span></p>";
document.getElementById('caption').innerHTML = newHTML;
};
this.clearChangeText = function(evt) {
// what do you want to do with that? There is no newHTML.value value!
newHTML.value =''; return false;
};
}
var classinstance = new ClassName();
call example:
Code:
classinstance.setLgImg('gallery/images/photo2.jpg','400','300');
Okay, I did not test it but it should work. Good Luck!
Max
Bookmarks