SSI with javacript - syntax problem.

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

    SSI with javacript - syntax problem.

    HI! I am trying to dynamically add content into Div tags with the use of
    JavaScript. it loads the page but adds a few characters. the script is
    below.

    <script language="JavaS cript">
    document.write( '<div id=DivExample>" <!--#include
    virtual="/Include_Pages_A sp/Main.htm" --></div>');
    </script>

    The characters that are added is right after the end of Main.htm page. they
    are as follows.

    ');

    I also get this JavaScript error in IE

    Line: 48
    Char:106
    Error:Untermina ted string constant.

    Since the page does load fully I suspect that Its a small syntax problem but
    I just don't know what.

    can someone tell me what I am doing wrong?

    --
    Thanks in advance :)

    Paul


  • rf

    #2
    Re: SSI with javacript - syntax problem.

    Paul wrote:[color=blue]
    > HI! I am trying to dynamically add content into Div tags with the use of
    > JavaScript. it loads the page but adds a few characters. the script is
    > below.
    >
    > <script language="JavaS cript">
    > document.write( '<div id=DivExample>" <!--#include
    > virtual="/Include_Pages_A sp/Main.htm" --></div>');
    > </script>
    >
    > The characters that are added is right after the end of Main.htm page.[/color]
    they[color=blue]
    > are as follows.
    >
    > ');
    >
    > I also get this JavaScript error in IE
    >
    > Line: 48
    > Char:106
    > Error:Untermina ted string constant.[/color]

    That should be a hint.

    Count the 's and the "s in the above document.write call.

    I see two 's but, oddly (pun intended), three "s. Three "s would usually
    cause an unterminated string somewhere. " to open the string but no closing
    ". You are at the mercy of error correction.

    I suspect the first " should not be there.

    Cheers
    Richard.


    Comment

    • Paul

      #3
      Re: SSI with javacript - syntax problem.

      HI! thanks for responding. It still does not work. I see in source
      view that it writes a one line then stops.

      I being told that Includes need to happen on the server, this
      include directive is being written out on the client by which time it's too
      late to include.

      Here is the link.


      How do load the page then?

      Paul

      "rf" <@invalid.com > wrote in message
      news:dLVQe.1530 9$FA3.1020@news-server.bigpond. net.au...[color=blue]
      > Paul wrote:[color=green]
      >> HI! I am trying to dynamically add content into Div tags with the use of
      >> JavaScript. it loads the page but adds a few characters. the script is
      >> below.
      >>
      >> <script language="JavaS cript">
      >> document.write( '<div id=DivExample>" <!--#include
      >> virtual="/Include_Pages_A sp/Main.htm" --></div>');
      >> </script>
      >>
      >> The characters that are added is right after the end of Main.htm page.[/color]
      > they[color=green]
      >> are as follows.
      >>
      >> ');
      >>
      >> I also get this JavaScript error in IE
      >>
      >> Line: 48
      >> Char:106
      >> Error:Untermina ted string constant.[/color]
      >
      > That should be a hint.
      >
      > Count the 's and the "s in the above document.write call.
      >
      > I see two 's but, oddly (pun intended), three "s. Three "s would usually
      > cause an unterminated string somewhere. " to open the string but no
      > closing
      > ". You are at the mercy of error correction.
      >
      > I suspect the first " should not be there.
      >
      > Cheers
      > Richard.
      >
      >[/color]


      Comment

      • web.dev

        #4
        Re: SSI with javacript - syntax problem.


        Paul wrote:[color=blue]
        > HI! thanks for responding. It still does not work. I see in source
        > view that it writes a one line then stops.
        >
        > I being told that Includes need to happen on the server, this
        > include directive is being written out on the client by which time it's too
        > late to include.
        >
        > Here is the link.
        > http://www.webcandesign.com/111/main_test_newnew.asp
        >
        > How do load the page then?
        >
        > Paul
        >
        > "rf" <@invalid.com > wrote in message
        > news:dLVQe.1530 9$FA3.1020@news-server.bigpond. net.au...[color=green]
        > > Paul wrote:[color=darkred]
        > >> HI! I am trying to dynamically add content into Div tags with the use of
        > >> JavaScript. it loads the page but adds a few characters. the script is
        > >> below.
        > >>
        > >> <script language="JavaS cript">
        > >> document.write( '<div id=DivExample>" <!--#include
        > >> virtual="/Include_Pages_A sp/Main.htm" --></div>');
        > >> </script>
        > >>
        > >> The characters that are added is right after the end of Main.htm page.[/color]
        > > they[color=darkred]
        > >> are as follows.
        > >>
        > >> ');
        > >>
        > >> I also get this JavaScript error in IE
        > >>
        > >> Line: 48
        > >> Char:106
        > >> Error:Untermina ted string constant.[/color]
        > >
        > > That should be a hint.
        > >
        > > Count the 's and the "s in the above document.write call.
        > >
        > > I see two 's but, oddly (pun intended), three "s. Three "s would usually
        > > cause an unterminated string somewhere. " to open the string but no
        > > closing
        > > ". You are at the mercy of error correction.
        > >
        > > I suspect the first " should not be there.
        > >
        > > Cheers
        > > Richard.
        > >
        > >[/color][/color]

        Hello Paul,

        If you're trying to do SSI with javascript, you're going about it all
        wrong. It's called Server Side Includes (SSI) for a reason. That being
        that it happens on the server side. You can attempt to do Client Side
        Includes, but believe me, that will get messy real fast. Here are some
        general solutions:

        For an ASP page:

        <!--#include virtual="filena me"-->
        or
        <!--#include file ="filename"-->

        For a PHP page:
        require("filena me");
        or
        include("filena me");

        For a SHTML page:
        <!--#include virtual="filena me"-->
        or
        <!--#include file ="filename"-->

        Hope this helps.

        Comment

        • Martin Kurz

          #5
          Re: SSI with javacript - syntax problem.

          Paul schrieb:[color=blue]
          > HI! I am trying to dynamically add content into Div tags with the use of
          > JavaScript. it loads the page but adds a few characters. the script is
          > below.
          >
          > <script language="JavaS cript">
          > document.write( '<div id=DivExample>" <!--#include
          > virtual="/Include_Pages_A sp/Main.htm" --></div>');
          > </script>
          >
          > The characters that are added is right after the end of Main.htm page. they
          > are as follows.
          >
          > ');
          >
          > I also get this JavaScript error in IE
          >
          > Line: 48
          > Char:106
          > Error:Untermina ted string constant.
          >
          > Since the page does load fully I suspect that Its a small syntax problem but
          > I just don't know what.
          >
          > can someone tell me what I am doing wrong?
          >[/color]

          Hi Paul,

          when i take a look at the pagespurce, I see something different than posted:

          document.write( <div id=DivExample>' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
          Transitional//EN">
          <html>
          ....
          </html>
          </div>');

          First of all: The text inside the () must be quoted (single or double), so it
          should be

          document.write( '<div id=DivExample>< !DOCTYPE HTML PUBLIC ...

          The next thing: There must nor be a line break inside the string. YIf you want
          to have breaks, you have to insert the breaks as \n (or \r\n for Windows-Style).
          Strings have to be concatenated (correctly written??) with +:

          document.write( '<div id=DivExample>< !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01'
          + ' Transitional//EN">'
          + '<html>');

          And the last thing: Why are you using JS-document.write and not inserting the
          SSI directly:

          <div id=DivExample>< !--#include > virtual="/Include_Pages_A sp/Main.htm" --></div>

          This (without the JS) should bring you to the wanted result.

          Greetings,

          Martin

          Comment

          • ASM

            #6
            Re: SSI with javacript - syntax problem.

            Paul wrote:[color=blue]
            > HI! I am trying to dynamically add content into Div tags with the use of
            > JavaScript. it loads the page but adds a few characters. the script is
            > below.
            >
            > <script language="JavaS cript">
            > document.write( '<div id=DivExample>" <!--#include
            > virtual="/Include_Pages_A sp/Main.htm" --></div>');
            > </script>[/color]

            <script language="JavaS cript"> is uncorrect

            a " (dble quote) is missing

            <script type="text/javascript">
            document.write( '<div id="DivExample> "'+
            '<!--#include virtual="/Include_Pages_A sp/Main.htm" -->'+
            '<\/div>');
            </script>

            allways an anti-slash before a slash next after a '<'
            or :
            '<'+'/div>'

            and ... what have you in your Main.htm ?

            --
            Stephane Moriaux et son [moins] vieux Mac

            Comment

            • Randy Webb

              #7
              Re: SSI with javacript - syntax problem.

              ASM said the following on 8/30/2005 7:55 PM:
              [color=blue]
              > Paul wrote:
              >[color=green]
              >> HI! I am trying to dynamically add content into Div tags with the use
              >> of JavaScript. it loads the page but adds a few characters. the script
              >> is below.
              >>
              >> <script language="JavaS cript">
              >> document.write( '<div id=DivExample>" <!--#include
              >> virtual="/Include_Pages_A sp/Main.htm" --></div>');
              >> </script>[/color]
              >
              >
              > <script language="JavaS cript"> is uncorrect
              >
              > a " (dble quote) is missing[/color]

              Where? The script tag you quoted shows the deprecated language attribute
              in quotes.
              [color=blue]
              > <script type="text/javascript">
              > document.write( '<div id="DivExample> "'+
              > '<!--#include virtual="/Include_Pages_A sp/Main.htm" -->'+
              > '<\/div>');
              > </script>
              >
              > allways an anti-slash before a slash next after a '<'
              > or :
              > '<'+'/div>'[/color]

              And it still won't work. It is because the include has already occured,
              or attempted to occur, before the script is ever executed.


              --
              Randy
              comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly

              Comment

              • ASM

                #8
                Re: SSI with javacript - syntax problem.

                Paul wrote:[color=blue]
                > HI! thanks for responding. It still does not work. I see in source
                > view that it writes a one line then stops.
                >
                > I being told that Includes need to happen on the server, this
                > include directive is being written out on the client by which time it's too
                > late to include.
                >
                > Here is the link.
                > http://www.webcandesign.com/111/main_test_newnew.asp
                >
                > How do load the page then?[/color]


                once more : what's content of 'Main.htm' ?

                because in the page is :

                document.write( <div id=DivExample>' <!DOCTYPE HTML ... >

                and a quote is yet missing ... !
                and,
                if there if a return carriage in 'Main.htm'
                it will not work

                You'ld have to set in 'Main.htm' :

                <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"<br>'+
                '"http://www.w3.org/TR/1998/REC-html40-19980424/loose.dtd">

                note the quotes (') and plus (+)

                so, in your JS :

                document.write( '<div id="DivExample" >'+
                '"/Include_Pages_A sp/Main.htm" --></div>');

                to get in end

                document.write( '<div id="DivExample" >'+
                '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"<br>'+
                '"http://www.w3.org/TR/1998/REC-html40-19980424/loose.dtd"><\/div>');


                --
                Stephane Moriaux et son [moins] vieux Mac

                Comment

                • Paul

                  #9
                  Re: SSI with javacript - syntax problem.

                  HI! thanks for the response. I am using it this form because I want to be
                  able to change the content. I want to be able to replace the include file
                  from a menu. Is there another way to do this without going this without
                  using the javascript in the way that I am using it?

                  Paul


                  "Martin Kurz" <info@martinkur z.in-berlin.de> wrote in message
                  news:1125439106 .427953@elch.in-berlin.de...[color=blue]
                  > Paul schrieb:[color=green]
                  >> HI! I am trying to dynamically add content into Div tags with the use of
                  >> JavaScript. it loads the page but adds a few characters. the script is
                  >> below.
                  >>
                  >> <script language="JavaS cript">
                  >> document.write( '<div id=DivExample>" <!--#include
                  >> virtual="/Include_Pages_A sp/Main.htm" --></div>');
                  >> </script>
                  >>
                  >> The characters that are added is right after the end of Main.htm page.
                  >> they
                  >> are as follows.
                  >>
                  >> ');
                  >>
                  >> I also get this JavaScript error in IE
                  >>
                  >> Line: 48
                  >> Char:106
                  >> Error:Untermina ted string constant.
                  >>
                  >> Since the page does load fully I suspect that Its a small syntax problem
                  >> but
                  >> I just don't know what.
                  >>
                  >> can someone tell me what I am doing wrong?
                  >>[/color]
                  >
                  > Hi Paul,
                  >
                  > when i take a look at the pagespurce, I see something different than
                  > posted:
                  >
                  > document.write( <div id=DivExample>' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML
                  > 4.01
                  > Transitional//EN">
                  > <html>
                  > ...
                  > </html>
                  > </div>');
                  >
                  > First of all: The text inside the () must be quoted (single or double), so
                  > it
                  > should be
                  >
                  > document.write( '<div id=DivExample>< !DOCTYPE HTML PUBLIC ...
                  >
                  > The next thing: There must nor be a line break inside the string. YIf you
                  > want
                  > to have breaks, you have to insert the breaks as \n (or \r\n for
                  > Windows-Style).
                  > Strings have to be concatenated (correctly written??) with +:
                  >
                  > document.write( '<div id=DivExample>< !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML
                  > 4.01'
                  > + ' Transitional//EN">'
                  > + '<html>');
                  >
                  > And the last thing: Why are you using JS-document.write and not inserting
                  > the
                  > SSI directly:
                  >
                  > <div id=DivExample>< !--#include >
                  > virtual="/Include_Pages_A sp/Main.htm" --></div>
                  >
                  > This (without the JS) should bring you to the wanted result.
                  >
                  > Greetings,
                  >
                  > Martin[/color]


                  Comment

                  • Paul

                    #10
                    Re: SSI with javacript - syntax problem.

                    HI! I don't the see the different between what you have shown me and what I
                    have done.

                    <!--#include virtual="/Include_Pages_A sp/Main.htm" -->

                    <!--#include virtual="filena me"-->

                    I am using asp. I dont understand the difference that you are pointing out.


                    Paul
                    "web.dev" <web.dev.cs@gma il.com> wrote in message
                    news:1125435850 .533548.262280@ o13g2000cwo.goo glegroups.com.. .[color=blue]
                    >
                    > Paul wrote:[color=green]
                    >> HI! thanks for responding. It still does not work. I see in source
                    >> view that it writes a one line then stops.
                    >>
                    >> I being told that Includes need to happen on the server, this
                    >> include directive is being written out on the client by which time it's
                    >> too
                    >> late to include.
                    >>
                    >> Here is the link.
                    >> http://www.webcandesign.com/111/main_test_newnew.asp
                    >>
                    >> How do load the page then?
                    >>
                    >> Paul
                    >>
                    >> "rf" <@invalid.com > wrote in message
                    >> news:dLVQe.1530 9$FA3.1020@news-server.bigpond. net.au...[color=darkred]
                    >> > Paul wrote:
                    >> >> HI! I am trying to dynamically add content into Div tags with the use
                    >> >> of
                    >> >> JavaScript. it loads the page but adds a few characters. the script is
                    >> >> below.
                    >> >>
                    >> >> <script language="JavaS cript">
                    >> >> document.write( '<div id=DivExample>" <!--#include
                    >> >> virtual="/Include_Pages_A sp/Main.htm" --></div>');
                    >> >> </script>
                    >> >>
                    >> >> The characters that are added is right after the end of Main.htm page.
                    >> > they
                    >> >> are as follows.
                    >> >>
                    >> >> ');
                    >> >>
                    >> >> I also get this JavaScript error in IE
                    >> >>
                    >> >> Line: 48
                    >> >> Char:106
                    >> >> Error:Untermina ted string constant.
                    >> >
                    >> > That should be a hint.
                    >> >
                    >> > Count the 's and the "s in the above document.write call.
                    >> >
                    >> > I see two 's but, oddly (pun intended), three "s. Three "s would
                    >> > usually
                    >> > cause an unterminated string somewhere. " to open the string but no
                    >> > closing
                    >> > ". You are at the mercy of error correction.
                    >> >
                    >> > I suspect the first " should not be there.
                    >> >
                    >> > Cheers
                    >> > Richard.
                    >> >
                    >> >[/color][/color]
                    >
                    > Hello Paul,
                    >
                    > If you're trying to do SSI with javascript, you're going about it all
                    > wrong. It's called Server Side Includes (SSI) for a reason. That being
                    > that it happens on the server side. You can attempt to do Client Side
                    > Includes, but believe me, that will get messy real fast. Here are some
                    > general solutions:
                    >
                    > For an ASP page:
                    >
                    > <!--#include virtual="filena me"-->
                    > or
                    > <!--#include file ="filename"-->
                    >
                    > For a PHP page:
                    > require("filena me");
                    > or
                    > include("filena me");
                    >
                    > For a SHTML page:
                    > <!--#include virtual="filena me"-->
                    > or
                    > <!--#include file ="filename"-->
                    >
                    > Hope this helps.
                    >[/color]


                    Comment

                    • Paul

                      #11
                      Re: SSI with javacript - syntax problem.

                      I wonder now is there is perhaps an easier way by creating a session
                      variable to load the string ( path of the include file) and then change the
                      string value via the menu . would work? this would mean the include file
                      would not to be modified and it would treated as normal include file. is
                      this correct?

                      Paul


                      "Randy Webb" <HikksNotAtHome @aol.com> wrote in message
                      news:39mdnazHyN eEa4neRVn-gw@comcast.com. ..[color=blue]
                      > ASM said the following on 8/30/2005 7:55 PM:
                      >[color=green]
                      >> Paul wrote:
                      >>[color=darkred]
                      >>> HI! I am trying to dynamically add content into Div tags with the use of
                      >>> JavaScript. it loads the page but adds a few characters. the script is
                      >>> below.
                      >>>
                      >>> <script language="JavaS cript">
                      >>> document.write( '<div id=DivExample>" <!--#include
                      >>> virtual="/Include_Pages_A sp/Main.htm" --></div>');
                      >>> </script>[/color]
                      >>
                      >>
                      >> <script language="JavaS cript"> is uncorrect
                      >>
                      >> a " (dble quote) is missing[/color]
                      >
                      > Where? The script tag you quoted shows the deprecated language attribute
                      > in quotes.
                      >[color=green]
                      >> <script type="text/javascript">
                      >> document.write( '<div id="DivExample> "'+
                      >> '<!--#include virtual="/Include_Pages_A sp/Main.htm" -->'+
                      >> '<\/div>');
                      >> </script>
                      >>
                      >> allways an anti-slash before a slash next after a '<'
                      >> or :
                      >> '<'+'/div>'[/color]
                      >
                      > And it still won't work. It is because the include has already occured, or
                      > attempted to occur, before the script is ever executed.
                      >
                      >
                      > --
                      > Randy
                      > comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly[/color]


                      Comment

                      • ASM

                        #12
                        Re: SSI with javacript - syntax problem.

                        Paul wrote:[color=blue]
                        > HI! I don't the see the different between what you have shown me and what I
                        > have done.[/color]

                        the differences are :

                        'virtual' is to use with a relative link
                        virtual="../folder/file.htm" : relative / page calling
                        virtual="/file.htm" : relative / root of site

                        'file' is to use with absolute link
                        file="http://sever/site/folder/page.htm"



                        --
                        Stephane Moriaux et son [moins] vieux Mac

                        Comment

                        • ASM

                          #13
                          Re: [HS SSI] SSI with javacript - syntax problem.

                          Paul wrote:[color=blue]
                          > HI! thanks for the response. I am using it this form because I want to be
                          > able to change the content. I want to be able to replace the include file
                          > from a menu. Is there another way to do this without going this without
                          > using the javascript in the way that I am using it?[/color]

                          the change of content with SSI can only be made by loading on server

                          You can use in SSI server request about url of document
                          then
                          get dynamicaly by SSI what it is expected

                          The JS will run after SSI instructions did
                          (and here : no need of JS)

                          here is a plan with SSI only
                          supposing sent url is this form :
                          'page.shtml?doc Type=4T'
                          or
                          'page.shtml?doc Type=41T'


                          file 'page.shtml' :

                          <!--#set var="Gotn" value="$QUERY_S TRING" -->

                          <!--#if expr="$Gotn = /. 4T ./" -->
                          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
                          "http://www.w3.org/TR/1998/REC-html40-19980424/loose.dtd">

                          <!--#elif expr="$Gotn = /. 4F ./" -->
                          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN"
                          "http://www.w3.org/TR/1998/REC-html40-19980424/frameset.dtd">

                          <!--#elif expr="$Gotn = /. 4S ./" -->
                          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
                          "http://www.w3.org/TR/1998/REC-html40-19980424/strict.dtd">


                          <!--#elif expr="$Gotn = /. 41T ./" -->
                          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                          "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">

                          <!--#endif -->

                          <html>
                          <head>
                          ....
                          </html>


                          SSI instruction :

                          <!--#if expr="$Gotn = /. 4T ./" -->

                          verify if '4T' exists inside value of ssi variable : $Gotn
                          that's : is string '4T' in url of called page ?

                          if yes, following html code is writen on page

                          if not, is ? :
                          <!--#elif expr=" ... blah ...



                          You can use this procedure to create on loading your menus



                          --
                          Stephane Moriaux et son [moins] vieux Mac

                          Comment

                          • ASM

                            #14
                            Re: SSI with javacript - syntax problem.

                            Randy Webb wrote:[color=blue]
                            > ASM said the following on 8/30/2005 7:55 PM:
                            >[/color]
                            [color=blue][color=green]
                            >> a " (dble quote) is missing[/color]
                            >
                            >
                            > Where? The script tag you quoted shows the deprecated language attribute
                            > in quotes.
                            >[color=green]
                            >> <script type="text/javascript">
                            >> document.write( '<div id="DivExample> "'+[/color][/color]
                            ^^^
                            here : -------------|
                            [color=blue][color=green]
                            >> '<!--#include virtual="/Include_Pages_A sp/Main.htm" -->'+
                            >> '<\/div>');
                            >> </script>
                            >>
                            >> allways an anti-slash before a slash next after a '<'
                            >> or :
                            >> '<'+'/div>'[/color]
                            >
                            >
                            > And it still won't work. It is because the include has already occured,
                            > or attempted to occur, before the script is ever executed.[/color]

                            no, it is because what is to include is not a string
                            ( doc type in 2 lines I think )



                            --
                            Stephane Moriaux et son [moins] vieux Mac

                            Comment

                            • Paul

                              #15
                              Re: SSI with javacript - syntax problem.

                              HI! And that's why I used virtual because its from the virtual root. I don't
                              understand why you are pointing it out then.

                              Paul


                              "ASM" <stephanemoriau x.NoAdmin@wanad oo.fr.invalid> wrote in message
                              news:4315923d$0 $20167$8fcfb975 @news.wanadoo.f r...[color=blue]
                              > Paul wrote:[color=green]
                              >> HI! I don't the see the different between what you have shown me and what
                              >> I have done.[/color]
                              >
                              > the differences are :
                              >
                              > 'virtual' is to use with a relative link
                              > virtual="../folder/file.htm" : relative / page calling
                              > virtual="/file.htm" : relative / root of site
                              >
                              > 'file' is to use with absolute link
                              > file="http://sever/site/folder/page.htm"
                              >
                              >
                              >
                              > --
                              > Stephane Moriaux et son [moins] vieux Mac[/color]


                              Comment

                              Working...