08-08-2006, 12:49 PM
I'm succesfully fetching an img element by it's ID, but I can't any of the properties' values, not even the id property.
I tried it both in Firefox and IE6 but to no avail.
Please help me solve this issue.
// fetch_object emulates document.getElementById
// and bridges over browser compatibility (it works, the problem is not here)
var buttonIcon = fetch_object(obj.id + '_icon');
The fetching works, but again, I can't get any of the properties' values so the alert function isn't functioning. What's even more weird, I tried the following code and it worked:
for (property in buttonIcon)
alert(proprty + "<br>");
All of the properties' names were printed out. I think I am going crazy. Why can't I get the properties values?
08-08-2006, 02:49 PM
Please post how the fetch_object() function looks like.
08-08-2006, 02:54 PM
How do you know that the function is working correctly? If it actually does work as you say, then the code you posted should also work. Even if you think the function is good, I'm thinking we'll still need to see it to determine what the problem might be...
08-08-2006, 03:08 PM
Sorry for the delay.
Here's the function:
else if (document.all)
else if (document.layers)
Actually I solved my problem. I had a loop searching for IDs to define objects using the IDs' names, and I forgot to set some of the IDs.
But a new problem is blocking me.
I'm defining a new property for an object in a funtion that 'initializes' (i.e. defining properties) for a set of objects.
At the end of this function I'm setting a new event handler function to handle mosue events. everything works, except the event handler can't access the new property I added. The new property is an element. (I do it this way:
obj.icon = getelementbyid("id");)
I have simplified your ideea and build a code which does what you want
As you see, it works:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
var obj = document.getElementById('mydiv')
On the other hand, I see that you use that fetch_object() to create objects according to the browsers modern/NS4/IE4
You are waisting your time. Almost no one use NS4, and absolutely no one IE4 these days. Why bother to complicate the code?
08-08-2006, 05:48 PM
Ok, take a look at this, and tell me if you see anything wrong, please:
this.init_controls = function()
// earlier in the script: this.controlbar = fetch_object('controls');
var controls = new Array();
//fetch_tags emulates document.getElementsByTagName
var buttons = fetch_tags(this.controlbar, 'div');
for (var i = 0; i < buttons.length; i++)
if (buttons[i].className == 'imagebutton' && buttons[i].id)
controls[controls.length] = buttons[i].id;
for (var i = 0; i < controls.length; i++)
var control = fetch_object(controls[i]);
this.init_command_button = function(obj)
obj.cmd = obj.id.substr(obj.id.indexOf('_cmd_') + 5);
obj.editorid = this.editorid;
this.buttons[obj.cmd] = obj;
obj.state = false;
obj.mode = 'normal';
// icon handlers
obj.icon = fetch_object(obj.id + '_icon');
// event handlers
obj.onclick = obj.onmousedown = obj.onmouseover = obj.onmouseout = Command_button_onmouseevent;
Command_button_onmouseevent = function(e)
if (e.type == 'click')
format(e, this.cmd, false, true);
button_context = function(obj, state, controltype)
// This function decides what style-state should be set for the current event
// I just thought I'd save reading theit's code for you
// Code summary:
set_control_style(obj, controltype, 'state');
set_control_style = function(obj, controltype, mode)
var properties = '';
for (property in obj.icon)
properties += property + '\n';
if (obj.mode != mode)
obj.mode = mode;
// This is where the button's style is set
The controlbar is built with many buttons whom syntax is like this:
<td id="controls" class="controlbar" colspan="2">
<div class="imagebutton" id="vB_Editor_001_cmd_italic">
<img id="cmd_[cmd]_icon" title="[stc]" src="[src]">