DHTML Woes...

Want to chit chat about anything, do it here ... posting here won't increase your post count (or shouldn't!). Please do not post any "phpBB" specific topics here unless they do not fit into the category above. Do not post bug reports, feature or support requests!
Forum rules
Please do not post any "phpBB" specific topics here unless they do not fit into the category above.

Do not post bug reports, feature or support requests! No really... Do not post bug reports, feature or support requests! Doing so will make Bertie a very sad bear indeed. :(
User avatar
dhn
Registered User
Posts: 1518
Joined: Wed Jul 04, 2001 8:10 am
Location: Around the corner
Contact:

Re: DHTML Woes...

Post by dhn »

Fubonis wrote: If I remember correctly, Microsoft Internet Explorer does not support getElementById. I think MSIE uses document.all(string).
IE does understand getElementByID.
Image

Pit
Registered User
Posts: 542
Joined: Tue Oct 08, 2002 5:13 pm
Location: Bling bling.
Contact:

Re: DHTML Woes...

Post by Pit »

FF8Jake wrote: My upcoming template for 2.0.*, Schlick
I hope it includes the phpBB copyright by the time it's finished.

FF8Jake
Registered User
Posts: 31
Joined: Wed Jun 11, 2003 2:43 pm
Location: An arrangement of pixels on your screen.
Contact:

Re: DHTML Woes...

Post by FF8Jake »

Pit wrote: FF8Jake wrote:My upcoming template for 2.0.*, Schlick

I hope it includes the phpBB copyright by the time it's finished.
It will. I've not decided what I want to do to the footer yet, but it will most likely be graphical like the rest of the template.
dhn wrote: Fubonis wrote:If I remember correctly, Microsoft Internet Explorer does not support getElementById. I think MSIE uses document.all(string).

IE does understand getElementByID.
After some research i've found it's IE not doing getAttribute() correctly. I setup a few alerts to echo what values getAttribute() returned, and they were correct in firefox, but "[object]" in IE.

Still researching...

User avatar
dhn
Registered User
Posts: 1518
Joined: Wed Jul 04, 2001 8:10 am
Location: Around the corner
Contact:

Re: DHTML Woes...

Post by dhn »

After some research i've found it's IE not doing getAttribute() correctly. I setup a few alerts to echo what values getAttribute() returned, and they were correct in firefox, but "[object]
" in IE.
That was what I assumed. A solution I am using most of the time would be:

Code: Select all

document.getElementById(id).style.display = "block";
and respectively

Code: Select all

document.getElementById(id).style.display = "hidden";
edit: object.style.display is always empty at the beginning, even if you assigned a css value to the object at hand, for instance:

Code: Select all

#example {
    display&#58 block;
}
So, you won't be able to check just for object.style.display == "block" on first call, but do also need to consider the initial state.

I suggest a function like:

Code: Select all

function toggle (id, initalState) {
   if (initialState == "closed" && document.getElementById(id).style.display == "") {
        //first case, in which the style.display of you element is empty
    }
}
Image

JPortal
Registered User
Posts: 117
Joined: Sun Nov 28, 2004 10:42 pm

Re: DHTML Woes...

Post by JPortal »

If you want a menu, check out my menu software (look at my sig). It supports context menus like you want and works across most browsers (Mozilla, Opera, IE 5.5+, etc).

Josh

Uchiha Nick
Registered User
Posts: 397
Joined: Tue Jul 20, 2004 6:21 am
Location: Rotterdam, The Netherlands
Contact:

Re: DHTML Woes...

Post by Uchiha Nick »

thats a nice template you made :wink:

just a question, will you update ( when it works ) it for phpBB Olympus?

P.S. wasnt Koholint Island from the GB game? just cant get at the name at the moment.. ( was stolen from me a long time ago so i kinda forgot )
Image

FF8Jake
Registered User
Posts: 31
Joined: Wed Jun 11, 2003 2:43 pm
Location: An arrangement of pixels on your screen.
Contact:

Re: DHTML Woes...

Post by FF8Jake »

Uchiha Nick wrote: thats a nice template you made :wink:

just a question, will you update ( when it works ) it for phpBB Olympus?

P.S. wasnt Koholint Island from the GB game? just cant get at the name at the moment.. ( was stolen from me a long time ago so i kinda forgot )
All will be revealed. ;) I really wasn't wanting anyone to know about the template until it was ready to go. Let's just say I have great plans for it. :)

As for further info about the template, i'd be glad to take PMs about it, instead of derailing this topic on the javascript problem. :mrgreen:

dhn: I hadn't thought about an initial state type setup. I'll give it a shot when I get home from work. Cheers.

FF8Jake
Registered User
Posts: 31
Joined: Wed Jun 11, 2003 2:43 pm
Location: An arrangement of pixels on your screen.
Contact:

Re: DHTML Woes...

Post by FF8Jake »

Finally solved the problem. IE very much screwed up the standards again. getAttribute and setAttribute support is very shoddy, though they claim it to be "supported". So, the solution? I knew from an earlier version of the menu(which didn't use a toggle, it used a seperate link to close the menu) that this code worked well in Firefox and IE:

Code: Select all

document.getElementById('foobar').style.display = 'block';
After trying to get a toggle to work, I stumbled upon setAttribute, and decided i'd code my function to be able to change whatever I wanted, not just the style. This worked awesome in firefox, but IE hates setAttribute and doesn't use it properly. So, scratch that idea. Eventually I resolved to eval()(which I had found through more googling) in a function to create a dynamic version of the first code I had used, one that let me decide which style I wanted to change through the array values. For the sake of simplicity, I made a toggler for images seperately. I also started storing an on/off value inside the array, instead of using getAttribute(which IE hates) to check the object's current status(kudos to dhn).

It works perfect in Mozilla and IE now. Thanks everyone, work goes on now, though if anyone wants to have another gander at the updated javascript and offer a suggestion I wouldn't mind. :)

DeadEye686
Registered User
Posts: 448
Joined: Mon Jul 21, 2003 7:18 pm
Contact:

Re: DHTML Woes...

Post by DeadEye686 »

It's fixed in Safari as well.

User avatar
xdarkday
Registered User
Posts: 50
Joined: Sat Apr 03, 2004 7:21 pm

Re: DHTML Woes...

Post by xdarkday »

i hope this will be open for download to the public. I love the viewtopic.

Post Reply