FireFox & simple Javascript

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

    #1

    FireFox & simple Javascript

    Hi everybody

    Wonder if you could help me out.

    I created a simple JavaScript routine to enable a user to click backwards
    and forwards between small news articles. This routine works fine in IE and
    Safari, but in the latest FireFox I get no title or article, but do see the
    prev and next links and the article number.

    My HTML and JS simple routine is as follows:

    <DIV CLASS="LatestNe wsTitle" ID="NewsTitle" NAME="NewsTitle ">&nbsp;</DIV>
    <DIV CLASS="LatestNe wsText" ID="NewsText" NAME="NewsText" >&nbsp;</DIV>

    <SPAN NAME="NewsPrev" ID="NewsPrev">< A HREF="JavaScrip t:void(0)"
    OnClick="NewsNe xtPrev(thepage-=1)">Prev</A></SPAN>

    <SPAN NAME="NewsNext" ID="NewsNext">< A HREF="javascrip t:void(0)"
    OnClick="NewsNe xtPrev(thepage+ =1)">Next</A></SPAN>

    <SCRIPT LANGUAGE="javas cript">
    <!--
    var thepage = 1;

    var thePrevEnabled = '<A HREF="javascrip t:void(0)"
    OnClick="NewsNe xtPrev(thepage-=1)">Prev</A>';
    var thePrevDisabled = '&nbsp;';

    var theNextEnabled = '<A HREF="javascrip t:void(0)"
    OnClick="NewsNe xtPrev(thepage+ =1)">Next</A>';
    var theNextDisabled = '&nbsp;';

    var theTitleText = new Array(1);
    var theParaText = new Array(1);
    theTitleText[1]='';
    theTitleText[1]+='e-mail warning';
    theParaText[1]='';
    theParaText[1]+='An e-mail from support@mydomai n.co.uk is not from us.';

    function NewsStartText() {
    self.NewsPrev.i nnerHTML = thePrevDisabled ;
    self.NewsNext.i nnerHTML = theNextDisabled ;

    self.NewsTitle. innerHTML = theTitleText[thepage];
    self.NewsText.i nnerHTML = theParaText[thepage];
    }

    function NewsNextPrev(th epage) {
    self.NewsPrev.i nnerHTML = thePrevDisabled ;
    self.NewsNext.i nnerHTML = theNextDisabled ;
    self.NewsTitle. innerHTML = theTitleText[thepage];
    self.NewsText.i nnerHTML = theParaText[thepage];
    return true;
    }

    NewsStartText()

    //-->
    </SCRIPT>

    As it has stumped as to why Safari works OK and not FireFox when I thought
    they 'fire off the same bat', do you have any idea as to what I'm doing
    wrong?

    Thanks

    Robbie

    PS: My Javascript functionality checkbox is ticked and it seems to be this
    specific script rather than JS in general.



  • Andrew Scott

    #2
    Re: FireFox &amp; simple Javascript

    Astra wrote:[color=blue]
    > Hi everybody
    >
    > Wonder if you could help me out.
    >
    > I created a simple JavaScript routine to enable a user to click backwards
    > and forwards between small news articles. This routine works fine in IE and
    > Safari, but in the latest FireFox I get no title or article, but do see the
    > prev and next links and the article number.
    >
    > My HTML and JS simple routine is as follows:
    >
    > <DIV CLASS="LatestNe wsTitle" ID="NewsTitle" NAME="NewsTitle ">&nbsp;</DIV>
    > <DIV CLASS="LatestNe wsText" ID="NewsText" NAME="NewsText" >&nbsp;</DIV>
    >
    > <SPAN NAME="NewsPrev" ID="NewsPrev">< A HREF="JavaScrip t:void(0)"
    > OnClick="NewsNe xtPrev(thepage-=1)">Prev</A></SPAN>
    >
    > <SPAN NAME="NewsNext" ID="NewsNext">< A HREF="javascrip t:void(0)"
    > OnClick="NewsNe xtPrev(thepage+ =1)">Next</A></SPAN>
    >
    > <SCRIPT LANGUAGE="javas cript">
    > <!--
    > var thepage = 1;
    >
    > var thePrevEnabled = '<A HREF="javascrip t:void(0)"
    > OnClick="NewsNe xtPrev(thepage-=1)">Prev</A>';
    > var thePrevDisabled = '&nbsp;';
    >
    > var theNextEnabled = '<A HREF="javascrip t:void(0)"
    > OnClick="NewsNe xtPrev(thepage+ =1)">Next</A>';
    > var theNextDisabled = '&nbsp;';
    >
    > var theTitleText = new Array(1);
    > var theParaText = new Array(1);
    > theTitleText[1]='';
    > theTitleText[1]+='e-mail warning';
    > theParaText[1]='';
    > theParaText[1]+='An e-mail from support@mydomai n.co.uk is not from us.';
    >
    > function NewsStartText() {
    > self.NewsPrev.i nnerHTML = thePrevDisabled ;
    > self.NewsNext.i nnerHTML = theNextDisabled ;
    >
    > self.NewsTitle. innerHTML = theTitleText[thepage];
    > self.NewsText.i nnerHTML = theParaText[thepage];
    > }
    >
    > function NewsNextPrev(th epage) {
    > self.NewsPrev.i nnerHTML = thePrevDisabled ;
    > self.NewsNext.i nnerHTML = theNextDisabled ;
    > self.NewsTitle. innerHTML = theTitleText[thepage];
    > self.NewsText.i nnerHTML = theParaText[thepage];
    > return true;
    > }
    >
    > NewsStartText()
    >
    > //-->
    > </SCRIPT>
    >
    > As it has stumped as to why Safari works OK and not FireFox when I thought
    > they 'fire off the same bat', do you have any idea as to what I'm doing
    > wrong?
    >
    > Thanks
    >
    > Robbie
    >
    > PS: My Javascript functionality checkbox is ticked and it seems to be this
    > specific script rather than JS in general.
    >
    >
    >[/color]
    Robbie

    To start NEVER use javascript: in the href of an anchor. Instead do the
    following.

    <a href="#" onclick="YourFu nctionCall(); return false">foo</a>

    And I assume you are only using an anchor because it woks with the CSS
    a:hover {} else you could have just used a span/div. Why? you ask hold
    the shift key and click the link.

    Also all tags and attribs should be in lower case.

    change <SCRIPT LANGUAGE="javas cript"> to <script type="text/javascript">

    I fail see why you are creating strings of html that for enabled and
    disabled. You can just change the disabled property of the anchor.

    Also can i suggest you use this to change the Text content of the div's

    var eNewsText = document.getEle mentById("NewsT ext");
    eNewsText.repla ceChild( document.create TextNode("The Content"),
    eNewsText.first Child );

    If you use propper DOM methods to reference and change the DOM you will
    have ALOT less issues x-browser.

    HTH
    Andy





    Comment

    • Richard Cornford

      #3
      Re: FireFox &amp; simple Javascript

      Astra wrote:
      <snip>[color=blue]
      > <SPAN NAME="NewsPrev" ID="NewsPrev">
      ><A HREF="JavaScrip t:void(0)"[/color]

      Executing a javascript pseudo-protocol HREF that does not replace the
      current page is the scripting equivalent of kicking the browser really
      hard. What will and will not function after you have done that is
      anyone's guess. Web browsers are fragile, they should not be kicked.
      [color=blue]
      > OnClick="NewsNe xtPrev(thepage-=1)">Prev</A></SPAN>[/color]

      If the onclick handler cancelled the navigation, by returning false, the
      HREF would never be activated and so would not be able to have harmful
      side effects. That would also make the contents of the HREF irrelevant
      to script supporting browser, and available to facilitate fall-back for
      script disabled browsers. It might, for example, contain the URL of the
      pertinent news article proper so the script incapable/disabled browser
      would navigate to that article (which seems quite an acceptable
      fall-back in this situation) and it would even allow users to employ
      that common context menu option of opening a link in a new browser
      window (if they wanted to; giving the user the choice is good).

      <snip>[color=blue]
      > <SCRIPT LANGUAGE="javas cript">[/color]

      In valid HTML 4 the TYPE attribute is required in a SCRIPT element, and
      proving it renders the deprecated LANGUAGE attribute redundant.
      [color=blue]
      > <!--[/color]

      The 'hide scripts from older browsers' stuff is for the benefit of
      browser so old that nobody will still be using them (as they will not
      function at all with any of the modern internet). Stop doing it.

      <snip>[color=blue]
      > function NewsNextPrev(th epage) {
      > self.NewsPrev.i nnerHTML = thePrevDisabled ;[/color]
      <snip> ^^^^^^^^

      The premise here is that a reference to an IDed DOM element is available
      as a named property of the window object in web browsers. That is a
      facility that Microsoft introduced, and others copied, but it is not
      part of any formal specification and not implemented in numerous
      browsers (including Mozilla/Firefox/Netscape/Gecko).

      This is covered in this group's FAQ:-

      <URL: http://www.jibbering.com/faq/ >

      Richard.


      Comment

      • Richard Cornford

        #4
        Re: FireFox &amp; simple Javascript

        Andrew Scott wrote:
        <snip>[color=blue]
        > And I assume you are only using an anchor because it
        > woks with the CSS a:hover {} else you could have just
        > used a span/div. Why? you ask hold the shift key and
        > click the link.[/color]

        It is not possible to keyboard navigate to a SPAN or a DIV [1], but it
        is possible to keyboard navigate to an A element.

        [1] Without providing a huge amount of additional code to monitor,
        contextualise and respond to keyboard input.
        [color=blue]
        > Also all tags and attribs should be in lower case.[/color]
        <snip>

        HTML element names and attributes may be in any case, including mixed
        case (and this is not an XHTML document, where lower case is required
        for official XHTML DTD-specified element names and attributes).

        Richard.


        Comment

        • Astra

          #5
          Re: FireFox &amp; simple Javascript

          Down below :0)

          "Andrew Scott" <Andrew@compan. net> wrote in message
          news:11b2q49tl8 anped@corp.supe rnews.com...
          Astra wrote:[color=blue]
          > Hi everybody
          >
          > Wonder if you could help me out.
          >
          > I created a simple JavaScript routine to enable a user to click backwards
          > and forwards between small news articles. This routine works fine in IE
          > and
          > Safari, but in the latest FireFox I get no title or article, but do see
          > the
          > prev and next links and the article number.
          >
          > My HTML and JS simple routine is as follows:
          >
          > <DIV CLASS="LatestNe wsTitle" ID="NewsTitle" NAME="NewsTitle ">&nbsp;</DIV>
          > <DIV CLASS="LatestNe wsText" ID="NewsText" NAME="NewsText" >&nbsp;</DIV>
          >
          > <SPAN NAME="NewsPrev" ID="NewsPrev">< A HREF="JavaScrip t:void(0)"
          > OnClick="NewsNe xtPrev(thepage-=1)">Prev</A></SPAN>
          >
          > <SPAN NAME="NewsNext" ID="NewsNext">< A HREF="javascrip t:void(0)"
          > OnClick="NewsNe xtPrev(thepage+ =1)">Next</A></SPAN>
          >
          > <SCRIPT LANGUAGE="javas cript">
          > <!--
          > var thepage = 1;
          >
          > var thePrevEnabled = '<A HREF="javascrip t:void(0)"
          > OnClick="NewsNe xtPrev(thepage-=1)">Prev</A>';
          > var thePrevDisabled = '&nbsp;';
          >
          > var theNextEnabled = '<A HREF="javascrip t:void(0)"
          > OnClick="NewsNe xtPrev(thepage+ =1)">Next</A>';
          > var theNextDisabled = '&nbsp;';
          >
          > var theTitleText = new Array(1);
          > var theParaText = new Array(1);
          > theTitleText[1]='';
          > theTitleText[1]+='e-mail warning';
          > theParaText[1]='';
          > theParaText[1]+='An e-mail from support@mydomai n.co.uk is not from us.';
          >
          > function NewsStartText() {
          > self.NewsPrev.i nnerHTML = thePrevDisabled ;
          > self.NewsNext.i nnerHTML = theNextDisabled ;
          >
          > self.NewsTitle. innerHTML = theTitleText[thepage];
          > self.NewsText.i nnerHTML = theParaText[thepage];
          > }
          >
          > function NewsNextPrev(th epage) {
          > self.NewsPrev.i nnerHTML = thePrevDisabled ;
          > self.NewsNext.i nnerHTML = theNextDisabled ;
          > self.NewsTitle. innerHTML = theTitleText[thepage];
          > self.NewsText.i nnerHTML = theParaText[thepage];
          > return true;
          > }
          >
          > NewsStartText()
          >
          > //-->
          > </SCRIPT>
          >
          > As it has stumped as to why Safari works OK and not FireFox when I thought
          > they 'fire off the same bat', do you have any idea as to what I'm doing
          > wrong?
          >
          > Thanks
          >
          > Robbie
          >
          > PS: My Javascript functionality checkbox is ticked and it seems to be this
          > specific script rather than JS in general.
          >
          >
          >[/color]
          Robbie

          To start NEVER use javascript: in the href of an anchor. Instead do the
          following.

          <a href="#" onclick="YourFu nctionCall(); return false">foo</a>

          And I assume you are only using an anchor because it woks with the CSS
          a:hover {} else you could have just used a span/div. Why? you ask hold
          the shift key and click the link.

          Also all tags and attribs should be in lower case.

          change <SCRIPT LANGUAGE="javas cript"> to <script type="text/javascript">

          I fail see why you are creating strings of html that for enabled and
          disabled. You can just change the disabled property of the anchor.

          Also can i suggest you use this to change the Text content of the div's

          var eNewsText = document.getEle mentById("NewsT ext");
          eNewsText.repla ceChild( document.create TextNode("The Content"),
          eNewsText.first Child );

          If you use propper DOM methods to reference and change the DOM you will
          have ALOT less issues x-browser.

          HTH
          Andy

          -----------------------------------

          Hi Andy

          Many thanks for the help. Having used the above getElement... I can now get
          the title and text to appear OK, but I can't get my prev and next links to
          work.

          I've changed the anchors to:

          <A HREF="#" OnClick="NewsNe xtPrev(thepage+ =1);return false">Next</A>
          <A HREF="#" OnClick="NewsNe xtPrev(thepage-=1);return false">Prev</A>

          and changed the JS to:

          var eNewsPrev = document.getEle mentById("NewsP rev");
          var eNewsNext = document.getEle mentById("NewsN ext");
          eNewsPrev.repla ceChild(
          document.create TextNode(thePre vDisabled),eNew sPrev.firstChil d );
          eNewsNext.repla ceChild(documen t.createTextNod e(theNextEnable d),eNewsNext.fi rstChild);but all I appear to get is the HTML as standard plain text rather thanactually show the HTML, eg instead of showing a Next link I'm seeing <AHREF="#" OnClick="NewsNe xtPrev(thepage+ =1);return false">Next</A> on thepage.Can this not be done via getEleement.... ?What was this anchor disabling that you were talking about?All I want to do is enable/disable the Next and Prev links as and when thereare news 'pages' to see.Rgds Robbie

          Comment

          • Andrew Scott

            #6
            Re: FireFox &amp; simple Javascript

            Richard Cornford wrote:[color=blue]
            > Andrew Scott wrote:
            > <snip>
            >[color=green]
            >>And I assume you are only using an anchor because it
            >>woks with the CSS a:hover {} else you could have just
            >>used a span/div. Why? you ask hold the shift key and
            >>click the link.[/color]
            >
            >
            > It is not possible to keyboard navigate to a SPAN or a DIV [1], but it
            > is possible to keyboard navigate to an A element.
            >
            > [1] Without providing a huge amount of additional code to monitor,
            > contextualise and respond to keyboard input.
            >
            >[color=green]
            >>Also all tags and attribs should be in lower case.[/color]
            >
            > <snip>
            >
            > HTML element names and attributes may be in any case, including mixed
            > case (and this is not an XHTML document, where lower case is required
            > for official XHTML DTD-specified element names and attributes).
            >
            > Richard.
            >
            >[/color]

            Richard

            Are suggesting that's the only reason Robbie used an anchor was to
            enable keyboard navigation of the page?

            To quote him "enable a user to click"

            And indeed XHTML is the only DOCTYPE where case is a requirement. But
            have said that it's always good to be consistant with the case.

            And IMHO it's best to learn to use lowercase asap if ever the event
            arises, which it did for me, that you need to change to use strict XHTML
            DOCTYPE it's just a matter of changeing the DOCTYPE and ensuring the
            arribs and elements are valid.

            Reduce that tagsoup...

            Andy





            Comment

            • Richard Cornford

              #7
              Re: FireFox &amp; simple Javascript

              Andrew Scott wrote:[color=blue]
              > Richard Cornford wrote:[color=green]
              >> Andrew Scott wrote:[/color][/color]
              <snip>[color=blue][color=green][color=darkred]
              >>>And I assume you are only using an anchor because it
              >>>woks with the CSS a:hover {} else you could have just
              >>>used a span/div. Why? you ask hold the shift key and
              >>>click the link.[/color]
              >>
              >>
              >> It is not possible to keyboard navigate to a SPAN or a DIV
              >> [1], but it is possible to keyboard navigate to an A element.[/color][/color]
              <snip>[color=blue][color=green][color=darkred]
              >>>Also all tags and attribs should be in lower case.[/color]
              >>
              >> <snip>
              >>
              >> HTML element names and attributes may be in any case,
              >> including mixed case (and this is not an XHTML document,
              >> where lower case is required for official XHTML DTD-specified
              >> element names and attributes).
              >>[/color][/color]
              <snip>[color=blue]
              > Are suggesting that's the only reason Robbie used an anchor
              > was to enable keyboard navigation of the page?[/color]

              I am pointing out that your proposed changes will result in a less
              accessible outcome because it will not be useable via a keyboard, at
              least not without considerable additional work.
              [color=blue]
              > To quote him "enable a user to click"[/color]

              That the OP may have a pointing-device oriented mindset is not a good
              reason for encouraging them to make changes that will potentially make
              things worse for some visitors to their site. It is also possible that
              the OP is living within a jurisdiction where a public information source
              in the form of a web site must be accessible by law (like the UK).
              [color=blue]
              > And indeed XHTML is the only DOCTYPE where case is a
              > requirement. But have said that it's always good to
              > be consistant with the case.[/color]

              Style advice can be given in a way that does not imply that its
              conclusions are required or necessary. There are many things that
              'should' or 'must' be done when authoring HTML, but using only lowercase
              characters in element and attribute names is not one of them.
              [color=blue]
              > And IMHO it's best to learn to use lowercase asap if ever
              > the event arises, which it did for me, that you need to
              > change to use strict XHTML DOCTYPE it's just a matter of
              > changeing the DOCTYPE and ensuring the arribs and elements
              > are valid.[/color]

              'Just a matter of changing the DOCTYPE'? You might just about get away
              with that in an HTML newsgroup, but this is a scripting newsgroup and we
              know that scripting XHTML involves using a different DOM, with its own
              requirements, characteristics and idiosyncrasies and so that most
              scripts would require large scale re-writing for use with XHTML.

              But yes, most of us will not have to deal with XHTML for a long time as
              we are working in a commercial context, where its use is made non-viable
              by the predominance of IE 6.
              [color=blue]
              > Reduce that tagsoup...[/color]

              You have set your own pit trap, are you now going to walk into it?

              Richard.


              Comment

              • Andrew Scott

                #8
                Re: FireFox &amp; simple Javascript

                Richard Cornford wrote:[color=blue]
                > Andrew Scott wrote:
                >[color=green]
                >>Richard Cornford wrote:
                >>[color=darkred]
                >>>Andrew Scott wrote:[/color][/color]
                >
                > <snip>
                >[color=green][color=darkred]
                >>>>And I assume you are only using an anchor because it
                >>>>woks with the CSS a:hover {} else you could have just
                >>>>used a span/div. Why? you ask hold the shift key and
                >>>>click the link.
                >>>
                >>>
                >>>It is not possible to keyboard navigate to a SPAN or a DIV
                >>>[1], but it is possible to keyboard navigate to an A element.[/color][/color]
                >
                > <snip>
                >[color=green][color=darkred]
                >>>>Also all tags and attribs should be in lower case.
                >>>
                >>><snip>
                >>>
                >>>HTML element names and attributes may be in any case,
                >>>including mixed case (and this is not an XHTML document,
                >>>where lower case is required for official XHTML DTD-specified
                >>>element names and attributes).
                >>>[/color][/color]
                >
                > <snip>
                >[color=green]
                >>Are suggesting that's the only reason Robbie used an anchor
                >>was to enable keyboard navigation of the page?[/color]
                >
                >
                > I am pointing out that your proposed changes will result in a less
                > accessible outcome because it will not be useable via a keyboard, at
                > least not without considerable additional work.
                >
                >[color=green]
                >>To quote him "enable a user to click"[/color]
                >
                >
                > That the OP may have a pointing-device oriented mindset is not a good
                > reason for encouraging them to make changes that will potentially make
                > things worse for some visitors to their site. It is also possible that
                > the OP is living within a jurisdiction where a public information source
                > in the form of a web site must be accessible by law (like the UK).
                >
                >[color=green]
                >>And indeed XHTML is the only DOCTYPE where case is a
                >>requirement . But have said that it's always good to
                >>be consistant with the case.[/color]
                >
                >
                > Style advice can be given in a way that does not imply that its
                > conclusions are required or necessary. There are many things that
                > 'should' or 'must' be done when authoring HTML, but using only lowercase
                > characters in element and attribute names is not one of them.
                >
                >[color=green]
                >>And IMHO it's best to learn to use lowercase asap if ever
                >>the event arises, which it did for me, that you need to
                >>change to use strict XHTML DOCTYPE it's just a matter of
                >>changeing the DOCTYPE and ensuring the arribs and elements
                >>are valid.[/color]
                >
                >
                > 'Just a matter of changing the DOCTYPE'? You might just about get away
                > with that in an HTML newsgroup, but this is a scripting newsgroup and we
                > know that scripting XHTML involves using a different DOM, with its own
                > requirements, characteristics and idiosyncrasies and so that most
                > scripts would require large scale re-writing for use with XHTML.
                >
                > But yes, most of us will not have to deal with XHTML for a long time as
                > we are working in a commercial context, where its use is made non-viable
                > by the predominance of IE 6.
                >
                >[color=green]
                >>Reduce that tagsoup...[/color]
                >
                >
                > You have set your own pit trap, are you now going to walk into it?
                >
                > Richard.
                >
                >[/color]

                Richard

                Your points are are 100% valid and i must agree with all of them.

                And rereading my statment about case of tag I feel that i did sound a
                touch forthright and maybe i should have said "Can i suggest you use
                lowercase for tags and attribs, if only for easy of reading". Tell me
                what case do you use?

                Andy



                Comment

                • Astra

                  #9
                  Re: FireFox &amp; simple Javascript

                  Down below :0)

                  "Richard Cornford" <Richard@litote s.demon.co.uk> wrote in message
                  news:d8rqj0$5t5 $1$8302bc10@new s.demon.co.uk.. .
                  Astra wrote:
                  <snip>[color=blue]
                  > <SPAN NAME="NewsPrev" ID="NewsPrev">
                  ><A HREF="JavaScrip t:void(0)"[/color]

                  Executing a javascript pseudo-protocol HREF that does not replace the
                  current page is the scripting equivalent of kicking the browser really
                  hard. What will and will not function after you have done that is
                  anyone's guess. Web browsers are fragile, they should not be kicked.
                  [color=blue]
                  > OnClick="NewsNe xtPrev(thepage-=1)">Prev</A></SPAN>[/color]

                  If the onclick handler cancelled the navigation, by returning false, the
                  HREF would never be activated and so would not be able to have harmful
                  side effects. That would also make the contents of the HREF irrelevant
                  to script supporting browser, and available to facilitate fall-back for
                  script disabled browsers. It might, for example, contain the URL of the
                  pertinent news article proper so the script incapable/disabled browser
                  would navigate to that article (which seems quite an acceptable
                  fall-back in this situation) and it would even allow users to employ
                  that common context menu option of opening a link in a new browser
                  window (if they wanted to; giving the user the choice is good).

                  <snip>[color=blue]
                  > <SCRIPT LANGUAGE="javas cript">[/color]

                  In valid HTML 4 the TYPE attribute is required in a SCRIPT element, and
                  proving it renders the deprecated LANGUAGE attribute redundant.
                  [color=blue]
                  > <!--[/color]

                  The 'hide scripts from older browsers' stuff is for the benefit of
                  browser so old that nobody will still be using them (as they will not
                  function at all with any of the modern internet). Stop doing it.

                  <snip>[color=blue]
                  > function NewsNextPrev(th epage) {
                  > self.NewsPrev.i nnerHTML = thePrevDisabled ;[/color]
                  <snip> ^^^^^^^^

                  The premise here is that a reference to an IDed DOM element is available
                  as a named property of the window object in web browsers. That is a
                  facility that Microsoft introduced, and others copied, but it is not
                  part of any formal specification and not implemented in numerous
                  browsers (including Mozilla/Firefox/Netscape/Gecko).

                  This is covered in this group's FAQ:-

                  <URL: http://www.jibbering.com/faq/ >

                  Richard.


                  Dear Andrew/Richard

                  Thanks for the feedback.

                  I've tried the innerHTML, but it doesn't seem to kick in, eg:

                  By default my HTML code now looks like:

                  <SPAN NAME="NewsPrev" ID="NewsPrev">< A HREF="#"
                  OnClick="NewsNe xtPrev(thepage-=1);return false">Prev</A></SPAN>

                  in my JS code I set the following vars:

                  var thePrevEnabled = '<A HREF="#" OnClick="NewsNe xtPrev(thepage-=1);return
                  false"><IMG SRC="skins/<%=cSkinsFolder Name%>/btn-prev.jpg" BORDER=0></A>';

                  var thePrevDisabled = '<A HREF="#"><IMG
                  SRC="skins/<%=cSkinsFolder Name%>/btn-prev-disabled.jpg" BORDER=0></A>';

                  further down the JS code I've set a literal test of:

                  document.getEle mentById("NewsP rev").InnerHTM L = "fred";

                  but nothing happens.

                  Having changed all the self's to getElementByIDs , my text actually works,
                  eg:

                  var eNewsText = document.getEle mentById("NewsT ext");
                  eNewsText.repla ceChild(documen t.createTextNod e(theParaText[thepage]),eNewsText.fir stChild);

                  now cycles through the text although HTML tags also appear as plain text as
                  well!!

                  If I used the style.visibilit y command line to show/hide the
                  disabled/enabled status then the whole thing works fine, but I want to show
                  an enabled/disabled button instead of nothing.

                  Can you help me get this InnerHTML to kick in.

                  Thanks

                  Robbie



                  Comment

                  • Astra

                    #10
                    Re: FireFox &amp; simple Javascript

                    false alarm!!

                    wasn't careful enough with my casing > InnerHTML should be innerHTML.

                    All sorted now.

                    Thanks

                    Robbie


                    "Astra" <No@Spam.com> wrote in message
                    news:11b56eugov 4jf03@corp.supe rnews.com...
                    Down below :0)

                    "Richard Cornford" <Richard@litote s.demon.co.uk> wrote in message
                    news:d8rqj0$5t5 $1$8302bc10@new s.demon.co.uk.. .
                    Astra wrote:
                    <snip>[color=blue]
                    > <SPAN NAME="NewsPrev" ID="NewsPrev">
                    ><A HREF="JavaScrip t:void(0)"[/color]

                    Executing a javascript pseudo-protocol HREF that does not replace the
                    current page is the scripting equivalent of kicking the browser really
                    hard. What will and will not function after you have done that is
                    anyone's guess. Web browsers are fragile, they should not be kicked.
                    [color=blue]
                    > OnClick="NewsNe xtPrev(thepage-=1)">Prev</A></SPAN>[/color]

                    If the onclick handler cancelled the navigation, by returning false, the
                    HREF would never be activated and so would not be able to have harmful
                    side effects. That would also make the contents of the HREF irrelevant
                    to script supporting browser, and available to facilitate fall-back for
                    script disabled browsers. It might, for example, contain the URL of the
                    pertinent news article proper so the script incapable/disabled browser
                    would navigate to that article (which seems quite an acceptable
                    fall-back in this situation) and it would even allow users to employ
                    that common context menu option of opening a link in a new browser
                    window (if they wanted to; giving the user the choice is good).

                    <snip>[color=blue]
                    > <SCRIPT LANGUAGE="javas cript">[/color]

                    In valid HTML 4 the TYPE attribute is required in a SCRIPT element, and
                    proving it renders the deprecated LANGUAGE attribute redundant.
                    [color=blue]
                    > <!--[/color]

                    The 'hide scripts from older browsers' stuff is for the benefit of
                    browser so old that nobody will still be using them (as they will not
                    function at all with any of the modern internet). Stop doing it.

                    <snip>[color=blue]
                    > function NewsNextPrev(th epage) {
                    > self.NewsPrev.i nnerHTML = thePrevDisabled ;[/color]
                    <snip> ^^^^^^^^

                    The premise here is that a reference to an IDed DOM element is available
                    as a named property of the window object in web browsers. That is a
                    facility that Microsoft introduced, and others copied, but it is not
                    part of any formal specification and not implemented in numerous
                    browsers (including Mozilla/Firefox/Netscape/Gecko).

                    This is covered in this group's FAQ:-

                    <URL: http://www.jibbering.com/faq/ >

                    Richard.


                    Dear Andrew/Richard

                    Thanks for the feedback.

                    I've tried the innerHTML, but it doesn't seem to kick in, eg:

                    By default my HTML code now looks like:

                    <SPAN NAME="NewsPrev" ID="NewsPrev">< A HREF="#"
                    OnClick="NewsNe xtPrev(thepage-=1);return false">Prev</A></SPAN>

                    in my JS code I set the following vars:

                    var thePrevEnabled = '<A HREF="#" OnClick="NewsNe xtPrev(thepage-=1);return
                    false"><IMG SRC="skins/<%=cSkinsFolder Name%>/btn-prev.jpg" BORDER=0></A>';

                    var thePrevDisabled = '<A HREF="#"><IMG
                    SRC="skins/<%=cSkinsFolder Name%>/btn-prev-disabled.jpg" BORDER=0></A>';

                    further down the JS code I've set a literal test of:

                    document.getEle mentById("NewsP rev").InnerHTM L = "fred";

                    but nothing happens.

                    Having changed all the self's to getElementByIDs , my text actually works,
                    eg:

                    var eNewsText = document.getEle mentById("NewsT ext");
                    eNewsText.repla ceChild(documen t.createTextNod e(theParaText[thepage]),eNewsText.fir stChild);

                    now cycles through the text although HTML tags also appear as plain text as
                    well!!

                    If I used the style.visibilit y command line to show/hide the
                    disabled/enabled status then the whole thing works fine, but I want to show
                    an enabled/disabled button instead of nothing.

                    Can you help me get this InnerHTML to kick in.

                    Thanks

                    Robbie




                    Comment

                    Working...