Topic: createElement("div") + IE? Pages that link to <a href="https://ozoneasylum.com/backlink?for=27802" title="Pages that link to Topic: createElement(&amp;quot;div&amp;quot;) + IE?" rel="nofollow" >Topic: createElement(&quot;div&quot;) + IE?\

 
Author Thread
Hugh
Paranoid (IV) Inmate

From: Dublin, Ireland
Insane since: Jul 2000

IP logged posted posted 04-18-2006 14:31 Edit Quote

In regards to the following code, is it normal that IE doesnt support this feature, or am I simply doing something wrong? This code works in Firefox. Am I forced to make a second version which writes elements using innerHTML ?

code:
divHandler = createDiv("corner4",10,30,30,30,null,null,50);
 document.body.appendChild(divHandler);



function createDiv(name,left,top,width,height,background,onmouseup,zIndex) {
 divHandle = document.createElement("div");
 divHandle.style.position = "absolute";
 divHandle.style.top = top + "px";
 divHandle.style.left = left + "px";
 divHandle.style.width = width + "px";
 divHandle.style.height = height + "px";

 if(zIndex) divHandle.style.zIndex = zIndex;
 if(background) divHandle.style.background = background;
 if(onmouseup) divHandle.style.onmouseup = onmouseup;

return divHandle;
}

poi
Paranoid (IV) Inmate

From: Norway
Insane since: Jun 2002

IP logged posted posted 04-18-2006 14:41 Edit Quote

works for me in IE 6.0.2900.blah.blah.blah xpsp2

Hugh
Paranoid (IV) Inmate

From: Dublin, Ireland
Insane since: Jul 2000

IP logged posted posted 04-18-2006 14:55 Edit Quote

Thanks for the speedy reply p01

I dont know wether to be relieved or even more angry at IE's debugging.

Does this page work for you in your version of IE? I have IE 6.0.2 aswell, but on win2k, could be a bug.

Do you see a big blue div?
http://www.icklepix.com/window/indexObjects.htm

(Nothing is clickable just yet in either browser, the above should display two boxes).

if your curious here is a working version which doesnt use objects and can only have one dialog box at a time:

http://www.icklepix.com/window/index1.htm

Could it be something to do with appending to the body? or returning the div object?

edit: url typo.

(Edited by Hugh on 04-18-2006 15:44)

Hugh
Paranoid (IV) Inmate

From: Dublin, Ireland
Insane since: Jul 2000

IP logged posted posted 04-18-2006 15:15 Edit Quote

Found this recently p01, seems like your kinda bag
http://www.theprodukkt.com/kkrieger.html
its a 96kb assembly game, amazing, you've probably seen it though.

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

IP logged posted posted 04-18-2006 15:16 Edit Quote

BTW divHandle.style.onmouseup = onmouseup

Should be
divHandle.onmouseup = onmouseup



.:[ Never resist a perfect moment ]:.

Hugh
Paranoid (IV) Inmate

From: Dublin, Ireland
Insane since: Jul 2000

IP logged posted posted 04-18-2006 15:45 Edit Quote

Well spotted, unfortunatly that wasnt the problem.

Hugh
Paranoid (IV) Inmate

From: Dublin, Ireland
Insane since: Jul 2000

IP logged posted posted 04-18-2006 15:49 Edit Quote

The IE debugger says

line 33, char 5, Code 0, Object does not support this property or method.

There is nothing at this point in any of the associated files, the nearest thing to it is:

for(i=0;i<divHandler.length;i++) document.body.appendChild(divHandler[i]);

in create.js

poi
Paranoid (IV) Inmate

From: Norway
Insane since: Jun 2002

IP logged posted posted 04-18-2006 17:01 Edit Quote

I've got the same error as you in IE

Have only checked create.js. When I do :

code:
javascript:alert( divHandle );void( 0 );

I get an array with 5 Objects, as expected, but when I do :

code:
javascript:alert( i );void( 0 );

it says [ object ] while it should display a number between 0 and 5.


Yep I already knew Kkrieger. It's done in C++, not assembly. But it's pretty impressive anyway

Hugh
Paranoid (IV) Inmate

From: Dublin, Ireland
Insane since: Jul 2000

IP logged posted posted 04-18-2006 17:52 Edit Quote

Oh christ, I have a form named i for input, I've been wrecking my head over this for ages, thanks man !

Thats done in C++ ? thats mad, I know hello world with all the standard libs is like 100kb :P

Hugh
Paranoid (IV) Inmate

From: Dublin, Ireland
Insane since: Jul 2000

IP logged posted posted 04-18-2006 19:50 Edit Quote

Am on track now, thanks again guys !

Hugh
Paranoid (IV) Inmate

From: Dublin, Ireland
Insane since: Jul 2000

IP logged posted posted 04-19-2006 01:08 Edit Quote

I have yet another problem now :

divHandle is a div created from within an object, with an id.

code:
divHandle.onmouseup = dothis();


works, but I want to pass the id of the object so I know what div has been clicked

code:
divHandle.onmouseup = dothis(this.id);


The above returns the div's "this" and not the object where it was spawned from and can't find .id, basically the command is being run from the div itself.

Anyone know how I could get around this? I was thinking it would have to revolve around the eval command somehow, but I couldnt figure it out and a listener isnt very practical.

Hugh
Paranoid (IV) Inmate

From: Dublin, Ireland
Insane since: Jul 2000

IP logged posted posted 04-19-2006 01:11 Edit Quote

is it possible to access a div's parent?

poi
Paranoid (IV) Inmate

From: Norway
Insane since: Jun 2002

IP logged posted posted 04-19-2006 01:48 Edit Quote

[quickReply_that_might_need_cross_browser_hacks_in_crappy_browsers]

When hooking an a function to an event handler, you must pass the handle of function, no a call to a function, so the syntax should be :

code:
function dothis( evt )
{
    var evt = evt||event,
        element = evt.target||evt.srcElement||this;

    alert( element.id +'\n'+ element.parentNode )
}

divHandle.onmouseup = dothis;

/!\ the code above is probably not 100% correct, but I can't be bothered to check it at ~2 o'clock after a few beers and before a short night.

Sure it's possible to acces the parent of a node, just use the parentNode property.

Anyway, hope that helps.

[/quickReply_that_might_need_cross_browser_hacks_in_crappy_browsers]



(Edited by poi on 04-19-2006 01:56)

TwoD
Bipolar (III) Inmate

From: Sweden
Insane since: Aug 2004

IP logged posted posted 04-19-2006 05:29 Edit Quote

Haha gotta love IE
btw, having access to the Asylum on my mobile rocks!

/TwoD

Hugh
Paranoid (IV) Inmate

From: Dublin, Ireland
Insane since: Jul 2000

IP logged posted posted 04-19-2006 18:11 Edit Quote

Hadn't even thought of an event ! Many thanks again, ye see this to be an interface for a final year project, so 1 thanks = 20+ regular thankss. I'm gonna keep an eye out see if I can help you with anything in further posts, although I think you completely out rank me in any progamming way

If that fails I might be able to do it with parentNode, though it could get very messy.

Hugh
Paranoid (IV) Inmate

From: Dublin, Ireland
Insane since: Jul 2000

IP logged posted posted 04-19-2006 19:05 Edit Quote

It works just fine btw !



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu