cleary1981
Programmer
Hi all,
I'm not sure of the terms I should be using but maybe you can understand what i am trying to do from my code.
My code generates an img object and defines the attributes. What I need to do is to add an event handler (onmousedown) to it. Has anyone any suggestions?
I'm not sure of the terms I should be using but maybe you can understand what i am trying to do from my code.
My code generates an img object and defines the attributes. What I need to do is to add an event handler (onmousedown) to it. Has anyone any suggestions?
Code:
function showObject() {
if (request.readyState == 4) {
var returned = request.responseText;
var splitResult = returned.split(" ");
var h = splitResult[0];
var w = splitResult[1]; // the dimensions must be set to a scale as they are to big for the screen. 25px represents 100mm
h = h/4;
w = w/4;
// this bit of code creates the new img object and sets the attributes
var yy = document.getElementById("container");
var newImgElement = document.createElement("img"); //create a new img element
newImgElement.className = "obj"; //for css reference
newImgElement.src = "box.gif";
newImgElement.id = g_objName; // set id=object until the object has been defined. must be renamed after to objName i think
newImgElement.border = 1;
newImgElement.height = h;
newImgElement.width = w;
yy.appendChild(newImgElement);