Javascript to OPTIONALLY hide HTML/JS

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David In NH

    Javascript to OPTIONALLY hide HTML/JS

    Hi all:

    Please excuse a newbie question but I could use some assistance.

    I have a large number of "help pages" for an application which we provide.
    Within those pages are sections of code that I want to conditionally comment
    out. These sections include HTML and Javascript elements. A sample:

    <p>For more information <script language="javas cript">advanced Help("
    <strong>Click Here</strong>","13.ht m");</scriptto launch the help page.

    I've tried to define functions optionalHelpSta rt and optionalHelpEnd which
    would either be defined as empty (if we want the code above to be executed)
    or as follows if we wanted to hide it:

    function optionalHelpSta rt()
    {
    document.write ("<!--");
    }

    function optionalHelpEnd ()
    {
    document.write< "-->");
    }

    and then recoding as follows:

    <script language="javas cript">optional HelpStart();</script>
    <p>For more information <script language="javas cript">advanced Help("
    <strong>Click Here</strong>","13.ht m");</scriptto launch the help page.
    <script language="javas cript">optional HelpEnd();</script>

    but this doesn't work (even if I put it all on a single line).

    Is there a simple way that I can get this to work? The major problem is that
    we've got two products, one which supports the "advancedHe lp" files and one
    that does not and we don't want to maintain two sets of files (there are
    something like 20 of them in each of 9 languages so far).

    Thanks in advance.

    - Dave


  • Tom de Neef

    #2
    Re: Javascript to OPTIONALLY hide HTML/JS

    "David In NH" <dgintz@gmail.c om>
    <snip>
    <p>For more information <script language="javas cript">advanced Help("
    <strong>Click Here</strong>","13.ht m");</scriptto launch the help page.
    >
    Can't you give <pa class and hide the lot via CSS in the product where you
    do not want to show this advanced help? It would remove all occurrences via
    one simple parameter.
    Tom


    Comment

    • David In NH

      #3
      Re: Javascript to OPTIONALLY hide HTML/JS


      "Tom de Neef" <tdeneef@qolor. nlwrote in message
      news:4804ab04$0 $14346$e4fe514c @news.xs4all.nl ...
      "David In NH" <dgintz@gmail.c om>
      <snip>
      >
      ><p>For more information <script language="javas cript">advanced Help("
      ><strong>Clic k Here</strong>","13.ht m");</scriptto launch the help page.
      >>
      >
      Can't you give <pa class and hide the lot via CSS in the product where
      you do not want to show this advanced help? It would remove all
      occurrences via one simple parameter.
      Tom
      >
      >
      Sorry Tom but I really am a newbie to this. I've inherited this work from
      the original programmer and am not familiar with CSS. I'll look into it
      though. Thanks for your suggestion.

      - David


      Comment

      • pr

        #4
        Re: Javascript to OPTIONALLY hide HTML/JS

        David In NH wrote:
        I have a large number of "help pages" for an application which we provide.
        Within those pages are sections of code that I want to conditionally comment
        out.
        [...]

        Sounds like you're trying to use JavaScript to counteract an authoring
        problem. You might get something to work - at least on users' PCs that
        have JavaScript available and enabled - but ISTM that you should be
        looking instead at:

        a. some kind of authoring system: content management software or a
        custom solution (eg XHTML + XSLT).

        b. server code (eg PHP, ASP) to disable the unwanted bits of web pages,
        probably triggered by the query string (eg
        'myhelp.html?pr oduct=standard| deluxe') and/or a cookie.

        (b) is the quicker. (a) is the more sensible. JavaScript doesn't have a
        lot going for it in this case.

        Comment

        • Tom de Neef

          #5
          Re: Javascript to OPTIONALLY hide HTML/JS


          "David In NH" <dgintz@gmail.c omschreef in bericht
          news:8sadnbY1_L JnMJnVnZ2dnUVZ_ qiinZ2d@comcast .com...
          >
          "Tom de Neef" <tdeneef@qolor. nlwrote in message
          news:4804ab04$0 $14346$e4fe514c @news.xs4all.nl ...
          >"David In NH" <dgintz@gmail.c om>
          ><snip>
          >>
          >><p>For more information <script language="javas cript">advanced Help("
          >><strong>Cli ck Here</strong>","13.ht m");</scriptto launch the help
          >>page.
          >>>
          >>
          >Can't you give <pa class and hide the lot via CSS in the product where
          >you do not want to show this advanced help? It would remove all
          >occurrences via one simple parameter.
          >Tom
          >>
          >>
          >
          Sorry Tom but I really am a newbie to this. I've inherited this work from
          the original programmer and am not familiar with CSS. I'll look into it
          though. Thanks for your suggestion.
          >
          - David
          <style>
          p.advanced {visible=no} // or {visible=yes} I am guessing here; check the
          styles applicable to <p>
          </style>

          <p class=advanceda ll text here will not show unless you change the
          stylesheet</p>

          Tom


          Comment

          • David In NH

            #6
            Re: Javascript to OPTIONALLY hide HTML/JS


            "Tom de Neef" <tdeneef@qolor. nlwrote in message
            news:4804d50d$0 $14348$e4fe514c @news.xs4all.nl ...
            >
            "David In NH" <dgintz@gmail.c omschreef in bericht
            news:8sadnbY1_L JnMJnVnZ2dnUVZ_ qiinZ2d@comcast .com...
            >>
            >"Tom de Neef" <tdeneef@qolor. nlwrote in message
            >news:4804ab04$ 0$14346$e4fe514 c@news.xs4all.n l...
            >>"David In NH" <dgintz@gmail.c om>
            >><snip>
            >>>
            >>><p>For more information <script language="javas cript">advanced Help("
            >>><strong>Clic k Here</strong>","13.ht m");</scriptto launch the help
            >>>page.
            >>>>
            >>>
            >>Can't you give <pa class and hide the lot via CSS in the product where
            >>you do not want to show this advanced help? It would remove all
            >>occurrences via one simple parameter.
            >>Tom
            >>>
            >>>
            >>
            >Sorry Tom but I really am a newbie to this. I've inherited this work from
            >the original programmer and am not familiar with CSS. I'll look into it
            >though. Thanks for your suggestion.
            >>
            >- David
            >
            <style>
            p.advanced {visible=no} // or {visible=yes} I am guessing here; check the
            styles applicable to <p>
            </style>
            >
            <p class=advanceda ll text here will not show unless you change the
            stylesheet</p>
            >
            Tom
            >
            Tom! You be da man! This is close to what I eventually winded up using (a
            little bit of Javascript that expands to code similar to what you
            suggested).

            My work just got a lot easier!


            Comment

            • Gregor Kofler

              #7
              Re: Javascript to OPTIONALLY hide HTML/JS

              Tom de Neef meinte:
              <style>
              p.advanced {visible=no} // or {visible=yes} I am guessing here; check the
              styles applicable to <p>
              </style>
              Rather set element.style.d isplay to either "block" or "none".

              You don't need to switch css classes.

              Gregor



              --
              http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
              http://web.gregorkofler.com ::: meine JS-Spielwiese
              http://www.image2d.com ::: Bildagentur für den alpinen Raum

              Comment

              • Thomas 'PointedEars' Lahn

                #8
                Re: Javascript to OPTIONALLY hide HTML/JS

                Tom de Neef wrote:
                "David In NH" <dgintz@gmail.c omschreef in bericht
                >"Tom de Neef" <tdeneef@qolor. nlwrote in message
                >>Can't you give <pa class and hide the lot via CSS in the product where
                >>you do not want to show this advanced help? It would remove all
                >>occurrences via one simple parameter.
                [...]
                <style>
                p.advanced {visible=no} // or {visible=yes} I am guessing here; check the
                styles applicable to <p>
                </style>
                If you are *this* sure, please refrain from posting your code in the future.
                This does not even come close to CSS. Should be:

                <style type="text/css">
                p.advanced {
                display: none;
                }
                </style>
                <p class=advanceda ll text here will not show unless you change the
                stylesheet</p>
                All attribute values should be quoted.


                PointedEars
                --
                var bugRiddenCrashP ronePieceOfJunk = (
                navigator.userA gent.indexOf('M SIE 5') != -1
                && navigator.userA gent.indexOf('M ac') != -1
                ) // Plone, register_functi on.js:16

                Comment

                Working...