SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Evangelist
    Join Date
    Jan 2002
    Location
    Scotland, UK
    Posts
    530
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Some of my DHTML code doesnt work on Opera / Mozilla :(

    Hi folks,

    I've used a little snipper of javascript/dhtml code borrowed from the SitePoint forums (which has now been taken offline for some reason).

    It works great under IE but wont play ball under Mozilla (1.0 and 1.1) and Opera 6.xx.

    I know its probably just my inexperience so I thought I'd ask the people in the know if they could have a quick look at the code for me.

    The code in question is activated when you click the little Txt File icon located beside Job Titles and Employment Status.

    Thanks.

    URL :

    http://www.v-dm.com/test/section0.htm

  2. #2
    morphine for a wooden leg randem's Avatar
    Join Date
    Jun 2002
    Location
    .chicago.il.us
    Posts
    957
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Direct references to elements by id only work in IE. The actual standard requires you to use getElementById().
    Code:
    function expandx(listID) {
       elem = getElementById(listID);
       if(elem.style.display=="none") {
          elem.style.display="";
       }else {
          elem.style.display="none";
       }
    }
    Which you can then call in the same way, except that you'll need quotes around the listID. eg: expandx('HELPA');

    Of course, Opera does some funny things with the style references in JS, but lets get one thing working before we go on to the next.
    ----Adopt-a-Sig----
    Your message here!

  3. #3
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you guys don't mind, I'll throw in a little optimization here
    Code:
    function expandx(listID) {
       elem = getElementById(listID);
       elem.style.display = (elem.style.display=="none") ? "" : "none" ;
       }
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev





Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •