[thelist] DOM + IE elements creation problem

Misha Genkin misha.genkin at gmail.com
Tue Nov 8 09:20:14 CST 2005


Chris,

Using style a associative array is described in a several W3C document, so I
think that it shouldn't be the source of the problem.
I'm afraid there is no available URL at which you could check this code, but
I'll be more than willing to detangle it, if it'll help.
Another problem is that the code doesn't fail, it works seamingly at 100%
but without the desired result when using IE. I've tried using alerts and
haven't found any problems, also IE doesn't show any error messages. When
using Firefox browser, this script works seamlessly.

Detangled code for your review:
for (i = 0; i < wysiwygEditor.menuRes.emoticons.length - 3; i ++)
{
	xAnchor = document.createElement("a");
	xAnchor.href = "#";
	xAnchor.onclick = menuEventHandler;
	xEl = document.createElement("img");
	var sEmoticonData = wysiwygEditor.menuRes.emoticons[i];
	aTemp = sEmoticonData.split(";;");
	xEl.id = "insertImage;" + aTemp[i] + ";" + nID
	var sBaseURL = wysiwygEditor.menuRes.emoticons.baseURL;
	var sFileType = wysiwygEditor.menuRes.emoticons.fileType;
	xEl.src = sBaseURL + aTemp[0] + sFileType;
		if (aTemp[1].indexOf("xClass") == -1)
            {
            	aCSS = aTemp[1].split(";");
            	for (i = 0; i < aCSS.length; i++)
			{
				var nValueIndex = aCSS[i].indexOf(":");
				var sPropery =
aCSS[i].substring(0,nValueIndex);
				var sValue = aCSS[i].substr(nValueIndex +
1);
				xEl.style[sProperty] = sValue;
			}
            }
            else xEl.className = aTemp[1].substr(7);

            xEl.alt = aTemp[2];
            xAnchor.appendChild(xEl);
		var sContainerID = "real" + sType + nID;
            document.getElementById(sContainerID).appendChild(xAnchor);
}

I hope this version of the code is more understandable.
Misha Genkin.

-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Christian Heilmann
Sent: Tuesday, November 08, 2005 2:02 PM
To: thelist at lists.evolt.org
Subject: Re: [thelist] DOM + IE elements creation problem

> Hi Matt
>
> I've tried to use hyphens instead of ";" but it didn't help.
> Also I'm using the ";" character in several more place as identifiers, and
> none caused any trouble yet.
> Do you have any others ideas? I'm out in the dark here :\

I am not sure you can use the style as an array

xEl.style[aCSS[i].substring(0,
aCSS[i].indexOf(":"))] = aCSS[i].substr(aCSS[i].indexOf(":") + 1);

isn't there a "." missing somewhere?

all of this would be a lot easier if you'd detangle your code a bit,
and use more variables. Or give us a URL to check it at.

It'd also help if MSIE had error messages that do make any sense. Did
you try to put alerts in and see exactly after which line it fails?

--
Chris Heilmann
Blog: http://www.wait-till-i.com
Writing: http://icant.co.uk/
Binaries: http://www.onlinetools.org/
-- 

* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester 
and archives of thelist go to: http://lists.evolt.org 
Workers of the Web, evolt ! 




More information about the thelist mailing list