Collapsible Content?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • clintonG

    #1

    Collapsible Content?

    Can somebody direct me to documents or source that supports the use of
    collapsible content that is collapsed by default when the page is loaded?
    The secondary objective would of course be cross-browser support.for IE
    (5-6) and browsers derived from Mozilla (varies). Thank you...

    <%= Clinton Gallagher


  • RobG

    #2
    Re: Collapsible Content?

    clintonG wrote:[color=blue]
    > Can somebody direct me to documents or source that supports the use of
    > collapsible content that is collapsed by default when the page is loaded?
    > The secondary objective would of course be cross-browser support.for IE
    > (5-6) and browsers derived from Mozilla (varies). Thank you...[/color]

    Doing what you ask is fairly easy, however to do it properly
    will requires a bit of thought.

    Making content "collapsed by default" can be achieved two ways -
    the simple way is to make the display property of the collapsed
    bits 'none', then use JavaScript to set it to '', but this
    approach is flawed.

    If content is to be revealed by JS, then a better idea is to
    have content visible by default, then hide it with JavaScript
    when the page loads. That way, if the user's JavaScript is
    disabled or their browser doesn't support it, they can still use
    your page.

    You can make the initial hide function run onload, however if
    there is a fair bit of content to load in your page before
    the onload runs, the user will see the divs displayed, then
    hidden. So put it just after the divs to collapse.

    Sample below.

    <html><head><ti tle>play</title>
    </head><body>
    <style type="text/css">
    .outer {border: 1px solid blue; background-color: #7777dd;
    color: #000066; padding: 5px;}
    .inner {border: 1px solid blue; background-color: #eeeeff;
    color: #333366;}
    </style>
    <script type="text/javascript">
    function toggleDisplay(x ) {
    if (x.style) {
    if (x.style.displa y == '') {
    x.style.display ='none'
    } else {
    x.style.display ='';
    }
    }
    }
    </script>
    </head><body>

    <div class="outer">< span onclick="
    toggleDisplay(t his.nextSibling );">Click to display/hide
    content</span><div class="inner">H ere is the content
    Here is the content Here is the content Here is the content
    Here is the content Here is the content Here is the content
    Here is the content Here is the content Here is the content
    Here is the content Here is the content Here is the content
    Here is the content Here is the content Here is the content
    Here is the content Here is the content Here is the content
    </div></div>

    <script type="text/javascript">
    if (document.getEl ementsByTagName ){
    var divs = document.getEle mentsByTagName( 'div');
    } else if (document.all) {
    var divs = document.all.ta gs('DIV');
    }
    for (var i=0, len=divs.length ; i<len; i++){
    if (divs[i].style && divs[i].className == 'inner') {
    divs[i].style.display = 'none';
    }
    }
    </script>
    </body></html>


    --
    Rob

    Comment

    • clintonG

      #3
      Re: Collapsible Content?



      "RobG" <rgqld@iinet.ne t.auau> wrote in message
      news:oYyLd.339$ Ud4.29490@news. optus.net.au...[color=blue]
      > clintonG wrote:[color=green]
      > > Can somebody direct me to documents or source that supports the use of
      > > collapsible content that is collapsed by default when the page is[/color][/color]
      loaded?[color=blue][color=green]
      > > The secondary objective would of course be cross-browser support.for IE
      > > (5-6) and browsers derived from Mozilla (varies). Thank you...[/color]
      >
      > Doing what you ask is fairly easy, however to do it properly
      > will requires a bit of thought.
      >
      > Making content "collapsed by default" can be achieved two ways -
      > the simple way is to make the display property of the collapsed
      > bits 'none', then use JavaScript to set it to '', but this
      > approach is flawed.
      >
      > If content is to be revealed by JS, then a better idea is to
      > have content visible by default, then hide it with JavaScript
      > when the page loads. That way, if the user's JavaScript is
      > disabled or their browser doesn't support it, they can still use
      > your page.
      >
      > You can make the initial hide function run onload, however if
      > there is a fair bit of content to load in your page before
      > the onload runs, the user will see the divs displayed, then
      > hidden. So put it just after the divs to collapse.
      >
      > Sample below.
      >
      > <html><head><ti tle>play</title>[/color]
      /* REDUNDANT ELEMENTS */[color=blue]
      > </head><body>[/color]
      /* REDUNDANT ELEMENTS */[color=blue]
      > <style type="text/css">
      > .outer {border: 1px solid blue; background-color: #7777dd;
      > color: #000066; padding: 5px;}
      > .inner {border: 1px solid blue; background-color: #eeeeff;
      > color: #333366;}
      > </style>
      > <script type="text/javascript">
      > function toggleDisplay(x ) {
      > if (x.style) {
      > if (x.style.displa y == '') {
      > x.style.display ='none'
      > } else {
      > x.style.display ='';
      > }
      > }
      > }
      > </script>
      > </head><body>
      >
      > <div class="outer">< span onclick="
      > toggleDisplay(t his.nextSibling );">Click to display/hide
      > content</span><div class="inner">H ere is the content
      > Here is the content Here is the content Here is the content
      > Here is the content Here is the content Here is the content
      > Here is the content Here is the content Here is the content
      > Here is the content Here is the content Here is the content
      > Here is the content Here is the content Here is the content
      > Here is the content Here is the content Here is the content
      > </div></div>
      >
      > <script type="text/javascript">
      > if (document.getEl ementsByTagName ){
      > var divs = document.getEle mentsByTagName( 'div');
      > } else if (document.all) {
      > var divs = document.all.ta gs('DIV');
      > }
      > for (var i=0, len=divs.length ; i<len; i++){
      > if (divs[i].style && divs[i].className == 'inner') {
      > divs[i].style.display = 'none';
      > }
      > }
      > </script>
      > </body></html>
      >
      >
      > --
      > Rob[/color]

      Thank you Rob.

      Note the code as shown includes redundant </head> and <body> tags
      which I delineate as shown above.

      The code does not function in FF or NS (Mozilla browsers) but it is very
      impressive when used with IE and nearly exactly what I want (especially
      the nice touch with the .outer and .inner classes so thank you again.

      I am going to spend some time with it to determine what methods may
      need to be modified to enable the script to function with Mozilla DNA
      (FF/NS browsers) which has been a real pain so far.

      I also need to use an iFrame within the div the inner class which will load
      a server-side page (aspx) to run wizards for account logins and such and
      then will need to determine how to collapse this.nextSiblin g once the
      server-side .aspx process has completed. Comments appreciated.

      I also just recalled reading that the use of the 'this' keyword is what may
      be problematic with Mozilla's event handlers. I'll try to verify that later
      this
      evening and hope to return with results.

      <%= Clinton Gallagher



      Comment

      • RobG

        #4
        Re: Collapsible Content?

        clintonG wrote:
        [...][color=blue]
        >
        > Thank you Rob.
        >
        > Note the code as shown includes redundant </head> and <body> tags
        > which I delineate as shown above.[/color]

        Err... copy/paste error. I
        [color=blue]
        >
        > The code does not function in FF or NS (Mozilla browsers) but it is very[/color]

        It should, I develop using Firefox and then test in IE. Even
        with the errant head and body tags, it works for me in all
        browsers I have.
        [color=blue]
        > impressive when used with IE and nearly exactly what I want (especially
        > the nice touch with the .outer and .inner classes so thank you again.
        >
        > I am going to spend some time with it to determine what methods may
        > need to be modified to enable the script to function with Mozilla DNA
        > (FF/NS browsers) which has been a real pain so far.[/color]

        If you use MS documentation and IE for development, that will be
        the case. Use Firefox/Mozilla/etc. and w3c specs and you'll
        have fewer issues, though you need a few tricks here and there
        to support older IE browsers and maybe Netscape 4 & 6.
        [color=blue]
        > I also need to use an iFrame within the div the inner class which will load
        > a server-side page (aspx) to run wizards for account logins and such and
        > then will need to determine how to collapse this.nextSiblin g once the
        > server-side .aspx process has completed. Comments appreciated.[/color]

        I used nextSibling as a convenience, rather than a
        getElementById or Tag method. You need to design the structure
        of your HTML to fit your model for creating dynamic content on
        the page.

        The idea is to create a link between the element that will be
        clicked on with the one that will be collapsed. This can be
        done with IDs or the relationship of the elements (e.g.
        nextSibling).

        Using ID requires some parsing either at the server or on the
        client to ensure the link points at the right element and all
        IDs remain unique in the page. e.g. your headings could all have
        enumerated ids: id="header-01" ..."header-02", etc. and the
        content to collapse: id="content-01" ..."content-02" etc.

        When the header is clicked on, if it's id="header-01" then
        collapse/expand element with id="content-01" (see sample below)

        Using element relationships restricts page layout options -
        change the layout and your relationship model may break. But
        it's not dependent on the generation of unique IDs, so you can
        just plonk the content on the page.
        [color=blue]
        > I also just recalled reading that the use of the 'this' keyword is what may
        > be problematic with Mozilla's event handlers. I'll try to verify that later
        > this
        > evening and hope to return with results.[/color]

        As far as I know, 'this' works fine in Mozilla. The event
        models in IE and the 'zillas are quite different, but that
        should not cause you any issues in this case.

        You can avoid using 'this' completely if you like and just pass
        "event" - see toggleDisplay0( ) below. If you want to get really
        fancy, you can add toggleDisplay() to all spans with
        id="header-" using JS when the page loads to save some coding -
        keeps the HTML clean.


        <html><head><ti tle>play</title>
        <style type="text/css">
        .outer {border: 1px solid blue; background-color: #7777dd;
        color: #000066; padding: 5px;}
        .inner {border: 1px solid blue; background-color: #eeeeff;
        color: #333366; padding: 5px;}
        </style>
        <script type="text/javascript">

        // Expects the element reference to be passed to it
        function toggleDisplay(i ) {
        var cont = i.id.split('-')[1];
        var x = document.getEle mentById('conte nt-' + cont);
        if (x.style) {
        if (x.style.displa y == '') {
        x.style.display ='none'
        } else {
        x.style.display ='';
        }
        }
        }

        // Uses the event to find the element clicked on
        function toggleDisplay0( e) {

        e = e || window.event;
        var y = e.target || e.srcElement;
        var n = y.id.split('-')[1];

        if (document.getEl ementById) {
        var x = document.getEle mentById('conte nt-' + n);
        } else if (document.al) {
        var x = document.all('c ontent-' + n);
        }

        if (x.style) {
        if (x.style.displa y == '') {
        x.style.display ='none'
        } else {
        x.style.display ='';
        }
        }
        }
        </script>
        </head><body>

        <div class="outer">< span id="header-01" onclick="
        toggleDisplay(t his);">Click to display/hide
        content 1</span><div class="inner" id="content-01">
        Here is the content 1 Here is the content 1
        Here is the content 1 Here is the content 1
        Here is the content 1 Here is the content 1
        Here is the content 1 Here is the content 1
        Here is the content 1 Here is the content 1
        </div></div>

        <div class="outer">< span id="header-02" onclick="
        toggleDisplay0( event);">Click to display/hide
        content 2</span><div class="inner" id="content-02">
        Here is the content 2 Here is the content 2
        Here is the content 2 Here is the content 2
        Here is the content 2 Here is the content 2
        Here is the content 2 Here is the content 2
        Here is the content 2 Here is the content 2
        </div></div>

        <script type="text/javascript">
        if (document.getEl ementsByTagName ){
        var divs = document.getEle mentsByTagName( 'div');
        } else if (document.all) {
        var divs = document.all.ta gs('DIV');
        }
        for (var i=0, len=divs.length ; i<len; i++){
        if (divs[i].style && divs[i].className == 'inner') {
        divs[i].style.display = 'none';
        }
        }
        </script>
        </body></html>



        --
        Rob

        Comment

        • clintonG

          #5
          Re: Collapsible Content?

          "RobG" <rgqld@iinet.ne t.auau> wrote in message
          news:%uVLd.363$ Ud4.30751@news. optus.net.au...[color=blue]
          > clintonG wrote:
          > [...][color=green]
          > >
          > > Thank you Rob.
          > >
          > > Note the code as shown includes redundant </head> and <body> tags
          > > which I delineate as shown above.[/color]
          >
          > Err... copy/paste error. I
          >[color=green]
          > >
          > > The code does not function in FF or NS (Mozilla browsers) but it is very[/color]
          >
          > It should, I develop using Firefox and then test in IE. Even
          > with the errant head and body tags, it works for me in all
          > browsers I have.
          >[color=green]
          > > impressive when used with IE and nearly exactly what I want (especially
          > > the nice touch with the .outer and .inner classes so thank you again.
          > >
          > > I am going to spend some time with it to determine what methods may
          > > need to be modified to enable the script to function with Mozilla DNA
          > > (FF/NS browsers) which has been a real pain so far.[/color]
          >
          > If you use MS documentation and IE for development, that will be
          > the case. Use Firefox/Mozilla/etc. and w3c specs and you'll
          > have fewer issues, though you need a few tricks here and there
          > to support older IE browsers and maybe Netscape 4 & 6.
          >[color=green]
          > > I also need to use an iFrame within the div the inner class which will[/color][/color]
          load[color=blue][color=green]
          > > a server-side page (aspx) to run wizards for account logins and such and
          > > then will need to determine how to collapse this.nextSiblin g once the
          > > server-side .aspx process has completed. Comments appreciated.[/color]
          >
          > I used nextSibling as a convenience, rather than a
          > getElementById or Tag method. You need to design the structure
          > of your HTML to fit your model for creating dynamic content on
          > the page.
          >
          > The idea is to create a link between the element that will be
          > clicked on with the one that will be collapsed. This can be
          > done with IDs or the relationship of the elements (e.g.
          > nextSibling).
          >
          > Using ID requires some parsing either at the server or on the
          > client to ensure the link points at the right element and all
          > IDs remain unique in the page. e.g. your headings could all have
          > enumerated ids: id="header-01" ..."header-02", etc. and the
          > content to collapse: id="content-01" ..."content-02" etc.
          >
          > When the header is clicked on, if it's id="header-01" then
          > collapse/expand element with id="content-01" (see sample below)
          >
          > Using element relationships restricts page layout options -
          > change the layout and your relationship model may break. But
          > it's not dependent on the generation of unique IDs, so you can
          > just plonk the content on the page.
          >[color=green]
          > > I also just recalled reading that the use of the 'this' keyword is what[/color][/color]
          may[color=blue][color=green]
          > > be problematic with Mozilla's event handlers. I'll try to verify that[/color][/color]
          later[color=blue][color=green]
          > > this
          > > evening and hope to return with results.[/color]
          >
          > As far as I know, 'this' works fine in Mozilla. The event
          > models in IE and the 'zillas are quite different, but that
          > should not cause you any issues in this case.
          >
          > You can avoid using 'this' completely if you like and just pass
          > "event" - see toggleDisplay0( ) below. If you want to get really
          > fancy, you can add toggleDisplay() to all spans with
          > id="header-" using JS when the page loads to save some coding -
          > keeps the HTML clean.
          >
          >
          > <html><head><ti tle>play</title>
          > <style type="text/css">
          > .outer {border: 1px solid blue; background-color: #7777dd;
          > color: #000066; padding: 5px;}
          > .inner {border: 1px solid blue; background-color: #eeeeff;
          > color: #333366; padding: 5px;}
          > </style>
          > <script type="text/javascript">
          >
          > // Expects the element reference to be passed to it
          > function toggleDisplay(i ) {
          > var cont = i.id.split('-')[1];
          > var x = document.getEle mentById('conte nt-' + cont);
          > if (x.style) {
          > if (x.style.displa y == '') {
          > x.style.display ='none'
          > } else {
          > x.style.display ='';
          > }
          > }
          > }
          >
          > // Uses the event to find the element clicked on
          > function toggleDisplay0( e) {
          >
          > e = e || window.event;
          > var y = e.target || e.srcElement;
          > var n = y.id.split('-')[1];
          >
          > if (document.getEl ementById) {
          > var x = document.getEle mentById('conte nt-' + n);
          > } else if (document.al) {
          > var x = document.all('c ontent-' + n);
          > }
          >
          > if (x.style) {
          > if (x.style.displa y == '') {
          > x.style.display ='none'
          > } else {
          > x.style.display ='';
          > }
          > }
          > }
          > </script>
          > </head><body>
          >
          > <div class="outer">< span id="header-01" onclick="
          > toggleDisplay(t his);">Click to display/hide
          > content 1</span><div class="inner" id="content-01">
          > Here is the content 1 Here is the content 1
          > Here is the content 1 Here is the content 1
          > Here is the content 1 Here is the content 1
          > Here is the content 1 Here is the content 1
          > Here is the content 1 Here is the content 1
          > </div></div>
          >
          > <div class="outer">< span id="header-02" onclick="
          > toggleDisplay0( event);">Click to display/hide
          > content 2</span><div class="inner" id="content-02">
          > Here is the content 2 Here is the content 2
          > Here is the content 2 Here is the content 2
          > Here is the content 2 Here is the content 2
          > Here is the content 2 Here is the content 2
          > Here is the content 2 Here is the content 2
          > </div></div>
          >
          > <script type="text/javascript">
          > if (document.getEl ementsByTagName ){
          > var divs = document.getEle mentsByTagName( 'div');
          > } else if (document.all) {
          > var divs = document.all.ta gs('DIV');
          > }
          > for (var i=0, len=divs.length ; i<len; i++){
          > if (divs[i].style && divs[i].className == 'inner') {
          > divs[i].style.display = 'none';
          > }
          > }
          > </script>
          > </body></html>
          >
          >
          >
          > --
          > Rob[/color]

          Your 2nd build does in fact function in IE and FF Rob. Thank you. It is also
          very helpful in the sense that I will be using similar header-01, header-02
          ids because the split will give me a value I can reuse to declare a src
          property for the file I want to load in the iFrame.

          FF oddity:
          <!-- will not display the hand onMouseOver but will with IE -->
          <span id="header-02" onclick="toggle Display0(event) ;"
          style="cursor:h and;">Click to display/hide content 2</span>

          IE and FF oddity:
          <!-- Attempting to replace span with semantic markup results in FF error:
          event is not defined -->
          <a id="header-02" href="javascrip t:toggleDisplay 0(event);">Clic k to
          display/hide content 2</a>

          Your advice to use FF and W3 DOM for development is noted and and is in
          progress.

          <%= Clinton




          Comment

          • RobG

            #6
            Re: Collapsible Content?

            clintonG wrote:
            [...][color=blue]
            >
            > Your 2nd build does in fact function in IE and FF Rob. Thank you. It is also
            > very helpful in the sense that I will be using similar header-01, header-02
            > ids because the split will give me a value I can reuse to declare a src
            > property for the file I want to load in the iFrame.
            >
            > FF oddity:
            > <!-- will not display the hand onMouseOver but will with IE -->
            > <span id="header-02" onclick="toggle Display0(event) ;"
            > style="cursor:h and;">Click to display/hide content 2</span>[/color]

            Maybe an HTML or CSS group can answer that.
            [color=blue]
            >
            > IE and FF oddity:
            > <!-- Attempting to replace span with semantic markup results in FF error:
            > event is not defined -->
            > <a id="header-02" href="javascrip t:toggleDisplay 0(event);">Clic k to
            > display/hide content 2</a>[/color]

            This is considered an abuse of <a href...>. The onclick event
            can be added to (almost) any element, so there is no need to
            subvert an <a> tag. The "correct" way to achieve events when
            clicking on an <a> is:

            <a href="usefulLin k.html"
            onclick="doSome thing(); return false;" ... >

            That way if JS is disabled, the user goes somewhere useful. If
            JS is enabled, the onclick runs and "return false" stops the
            link being followed. If there really is no link, href="#" works
            OK but it causes most browsers to scroll to the top of the page
            if the event isn't canceled (i.e. if JS disabled or you don't
            return false).

            Considering the purpose is to open/close content, better to add
            visual cues such as a "+" to the header when closed and "-" when
            open to indicate that clicking on the text will display more
            content. Maybe add a title attribute such as
            "Click to expand..."

            <a href="usefulLin k.html"
            onclick="doSome thing(); return false;"
            title="Click to expand..."> ... </a>

            --
            Rob

            Comment

            • RobB

              #7
              Re: Collapsible Content?

              RobG wrote:[color=blue]
              > clintonG wrote:
              > [...][color=green]
              > >
              > > Your 2nd build does in fact function in IE and FF Rob. Thank you.[/color][/color]
              It is also[color=blue][color=green]
              > > very helpful in the sense that I will be using similar header-01,[/color][/color]
              header-02[color=blue][color=green]
              > > ids because the split will give me a value I can reuse to declare a[/color][/color]
              src[color=blue][color=green]
              > > property for the file I want to load in the iFrame.
              > >
              > > FF oddity:
              > > <!-- will not display the hand onMouseOver but will with IE -->
              > > <span id="header-02" onclick="toggle Display0(event) ;"
              > > style="cursor:h and;">Click to display/hide content 2</span>[/color]
              >
              > Maybe an HTML or CSS group can answer that.[/color]

              .....style="cur sor:pointer;"> (IE, not FF, oddity).
              [color=blue][color=green]
              > > IE and FF oddity:
              > > <!-- Attempting to replace span with semantic markup results in FF[/color][/color]
              error:[color=blue][color=green]
              > > event is not defined -->
              > > <a id="header-02" href="javascrip t:toggleDisplay 0(event);">Clic k to
              > > display/hide content 2</a>[/color]
              >
              > This is considered an abuse of <a href...>. The onclick event
              > can be added to (almost) any element, so there is no need to
              > subvert an <a> tag. The "correct" way to achieve events when
              > clicking on an <a> is:
              >
              > <a href="usefulLin k.html"
              > onclick="doSome thing(); return false;" ... >
              >
              > That way if JS is disabled, the user goes somewhere useful. If
              > JS is enabled, the onclick runs and "return false" stops the
              > link being followed. If there really is no link, href="#" works
              > OK but it causes most browsers to scroll to the top of the page
              > if the event isn't canceled (i.e. if JS disabled or you don't
              > return false).[/color]

              (snip)

              As well, you can't pick up the (moz) Event object that way, as it's
              passed into the HTML event handler - in this case, Link.onclick - as
              the local variable 'event'. That javascript: url will execute with
              global scope, leaving 'event' undefined, as you observed.

              Comment

              • Martin Honnen

                #8
                Re: Collapsible Content?



                clintonG wrote:

                [color=blue]
                > FF oddity:
                > <!-- will not display the hand onMouseOver but will with IE -->
                > <span id="header-02" onclick="toggle Display0(event) ;"
                > style="cursor:h and;">Click to display/hide content 2</span>[/color]

                Well your CSS knowledge is the oddity, the value you probably want as
                defined in CSS 2 is pointer, see
                <http://www.w3.org/TR/CSS2/ui.html#cursor-props>
                so
                cursor: pointer;
                will do in browsers like Mozilla, Firefox or Opera implementing W3C
                standards. It also works in IE 6 but not earlier versions of IE on Win
                at least, there you would need what you have (hand).
                So use
                cursor: pointer;
                or check the archives of this group or CSS groups, in the right sequence
                (either cursor: pointer; cursor: hand; or cursor: hand; cursor:
                pointer;) you can make both IE 5/5.5 and the other browsers happy.
                [color=blue]
                > IE and FF oddity:
                > <!-- Attempting to replace span with semantic markup results in FF error:
                > event is not defined -->
                > <a id="header-02" href="javascrip t:toggleDisplay 0(event);">Clic k to
                > display/hide content 2</a>[/color]

                Event handlers are onclick, onmousedown etc, if you put script in the
                href attribute in the form of a javascript: URL then there is no event
                object. You likely want
                <a href="#"
                onclick="toggle Dislay0(event); return false;">

                --

                Martin Honnen
                http://JavaScript.FAQTs.com/

                Comment

                • clintonG

                  #9
                  Re: Collapsible Content?


                  "Martin Honnen" <mahotrash@yaho o.de> wrote in message
                  news:42009ce8$0 $822$9b4e6d93@n ewsread2.arcor-online.net...[color=blue]
                  >
                  >
                  > clintonG wrote:
                  >
                  >[color=green]
                  > > FF oddity:
                  > > <!-- will not display the hand onMouseOver but will with IE -->
                  > > <span id="header-02" onclick="toggle Display0(event) ;"
                  > > style="cursor:h and;">Click to display/hide content 2</span>[/color]
                  >
                  > Well your CSS knowledge is the oddity, the value you probably want as
                  > defined in CSS 2 is pointer, see
                  > <http://www.w3.org/TR/CSS2/ui.html#cursor-props>
                  > so
                  > cursor: pointer;
                  > will do in browsers like Mozilla, Firefox or Opera implementing W3C
                  > standards. It also works in IE 6 but not earlier versions of IE on Win
                  > at least, there you would need what you have (hand).
                  > So use
                  > cursor: pointer;
                  > or check the archives of this group or CSS groups, in the right sequence
                  > (either cursor: pointer; cursor: hand; or cursor: hand; cursor:
                  > pointer;) you can make both IE 5/5.5 and the other browsers happy.
                  >[color=green]
                  > > IE and FF oddity:
                  > > <!-- Attempting to replace span with semantic markup results in FF[/color][/color]
                  error:[color=blue][color=green]
                  > > event is not defined -->
                  > > <a id="header-02" href="javascrip t:toggleDisplay 0(event);">Clic k to
                  > > display/hide content 2</a>[/color]
                  >
                  > Event handlers are onclick, onmousedown etc, if you put script in the
                  > href attribute in the form of a javascript: URL then there is no event
                  > object. You likely want
                  > <a href="#"
                  > onclick="toggle Dislay0(event); return false;">
                  >
                  > --
                  >
                  > Martin Honnen
                  > http://JavaScript.FAQTs.com/[/color]

                  Thank you for bringing the updated CSS pointer attribute value to my
                  attention.

                  <%= Clinton Gallagher




                  Comment

                  • clintonG

                    #10
                    Re: Collapsible Content?

                    <snip />
                    [color=blue]
                    > This is considered an abuse of <a href...>. The onclick event
                    > can be added to (almost) any element, so there is no need to
                    > subvert an <a> tag. The "correct" way to achieve events when
                    > clicking on an <a> is:
                    >
                    > <a href="usefulLin k.html"
                    > onclick="doSome thing(); return false;" ... >
                    >
                    > That way if JS is disabled, the user goes somewhere useful. If
                    > JS is enabled, the onclick runs and "return false" stops the
                    > link being followed. If there really is no link, href="#" works
                    > OK but it causes most browsers to scroll to the top of the page
                    > if the event isn't canceled (i.e. if JS disabled or you don't
                    > return false).
                    >
                    > Considering the purpose is to open/close content, better to add
                    > visual cues such as a "+" to the header when closed and "-" when
                    > open to indicate that clicking on the text will display more
                    > content. Maybe add a title attribute such as
                    > "Click to expand..."
                    >
                    > <a href="usefulLin k.html"
                    > onclick="doSome thing(); return false;"
                    > title="Click to expand..."> ... </a>
                    >
                    > --
                    > Rob[/color]

                    Ah. I actually learned the proper way to call a scripted function from
                    within an anchored element some time ago but forgot and got sloppy. You're
                    right, it is the best solution and calling toggleDisplay0( event) as follows
                    now functions as desired.

                    <a id="header-02" href="BrowserRe quirements.aspx "
                    onClick="toggle Display0(event) ; return false;">

                    RobB brings up the point regarding the Mozilla event handling model. I found
                    the forum discussion which discussed issues related to the use of the 'this'
                    keyword with interesting statements regarding the Mozilla event handling
                    model.

                    That discussion topic was about naming conventions [1] but as it so often
                    happens the discussion moved OT when 'georgias' broaches the subject of the
                    use of the keyword with immediate conjecture from 'asqueella' and a cogent
                    response from 'Mook' who speaks to the fundamental issue of the keyword in
                    the context RobB reminds us is fundamental.

                    <Mook>
                    * If called as object.function ( ) then this is the object
                    * If called on an event handler, this is the element that triggered the
                    event
                    * If called via a reference to the function (in my case, passed it to
                    XPCOM), this is the function itself

                    All of this, of course, is evaluated when the function is executed, so if
                    you call it differently then the same variable in the function resolves to
                    different kinds of things...
                    </Mook>

                    BTW - MikeFoster (cross-browser.com) has implemented a demo [2] which models
                    the functionality we are all discussing.

                    Obviously there are many champions that advocate the use of DHTML to achieve
                    a rich user interface and I am grateful to all.

                    <%= Clinton Gallagher

                    [1] http://forums.mozillazine.org/viewtopic.php?t=129485
                    [2] http://cross-browser.com/toys/toolbars.html


                    Comment

                    • clintonG

                      #11
                      Re: Collapsible Content?

                      <snip />
                      (snip)[color=blue]
                      >
                      > As well, you can't pick up the (moz) Event object that way, as it's
                      > passed into the HTML event handler - in this case, Link.onclick - as
                      > the local variable 'event'. That javascript: url will execute with
                      > global scope, leaving 'event' undefined, as you observed.[/color]

                      Thank you for bringing this to the attention of this discussion Rob.
                      My reply to RobG includes discussion and references you may want
                      to respond to.

                      <%= Clinton Gallagher


                      Comment

                      Working...