Javascript equivalent of #include or @import?

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

    #16
    Re: Javascript equivalent of #include or @import?

    I use the following to include any file on the server :

    <!--#include file="yourfilen amehere.js"-->

    I'm not sure what support you need to run it. I use ASP for my server side
    programming but this
    isn't asp.
    Anyway, try it, if your server has even minimal support it should work.
    Remember, this is happening on the server. Javascript runs on the client. I
    fail to see how
    using javascript document.read or write is going to work unless everyone who
    visits your web page has the
    files on their computers!

    "gendem" <gendem@yahoo.c om> wrote in message
    news:in4h00he9i lt5navjh6hvcdud 0lt6jea7u@4ax.c om...[color=blue][color=green][color=darkred]
    > >>> I'm wondering if there's a way to include other pieces of javascript
    > >>> code from *within* javascript.... a la #include in C, @import in Java,
    > >>> use/require in Perl, include()/require() in PHP, etc....
    > >>
    > >> Not in general, no. If you want to include it while the page is being
    > >> loaded, you can use document.write to write a new Javascript tag:[/color][/color]
    >
    > Rats. I'm trying to script in PhotoShop, which uses Javascript, and
    > it sure is a waste to have to copy code around instead of just
    > including it. I guess it's a limitation of not seeing all potential
    > uses of a language before hand. Oh well.[/color]


    Comment

    • Randy Webb

      #17
      Re: Javascript equivalent of #include or @import?

      Simon Wigzell wrote:
      [color=blue]
      > To load any file into the current page from the server use :
      > <!--#include file="[filename]"-->This is server side code.Javascript runs on
      > the client so unless everyone who is going to visit your website has the
      > java files on their computers, what you want would not work![/color]

      Before offering javascript advice, one should learn the difference
      between java and javascript.

      Before posting to a usenet newsgroup, one should read its FAQ.


      --
      Randy
      Chance Favors The Prepared Mind
      comp.lang.javas cript FAQ - http://jibbering.com/faq/

      Comment

      • Simon Wigzell

        #18
        Re: Javascript equivalent of #include or @import?

        Oh please pardon me for my typo - I said "java" not "javascript " in my
        second use of the term. Do you disagree with the substance of my post? Is
        there a word for shits like you who go around trying to prove their
        superiority by picking on typos in other peoples posts? I've been
        programming for 15 years thanks very much. I'm trying to help someone, what
        are you doing you miserable maggot?


        "Randy Webb" <hikksnotathome @aol.com> wrote in message
        news:TLydnZCvTO 0flI7dRVn-hA@comcast.com. ..[color=blue]
        > Simon Wigzell wrote:
        >[color=green]
        > > To load any file into the current page from the server use :
        > > <!--#include file="[filename]"-->This is server side code.Javascript[/color][/color]
        runs on[color=blue][color=green]
        > > the client so unless everyone who is going to visit your website has the
        > > java files on their computers, what you want would not work![/color]
        >
        > Before offering javascript advice, one should learn the difference
        > between java and javascript.
        >
        > Before posting to a usenet newsgroup, one should read its FAQ.
        >
        >
        > --
        > Randy
        > Chance Favors The Prepared Mind
        > comp.lang.javas cript FAQ - http://jibbering.com/faq/
        >[/color]


        Comment

        • Simon Wigzell

          #19
          Re: Javascript equivalent of #include or @import?

          It's all explained here :

          http://www.htmlgoodies.com/beyond/ssi.html

          Hope this helps.


          Comment

          • Randy Webb

            #20
            Re: Javascript equivalent of #include or @import?

            Simon Wigzell wrote:
            [color=blue]
            > "Randy Webb" <hikksnotathome @aol.com> wrote in message
            > news:TLydnZCvTO 0flI7dRVn-hA@comcast.com. ..
            >[color=green]
            >>Simon Wigzell wrote:
            >>
            >>[color=darkred]
            >>> To load any file into the current page from the server use :
            >>><!--#include file="[filename]"-->This is server side code.Javascript[/color][/color]
            >
            > runs on
            >[color=green][color=darkred]
            >>>the client so unless everyone who is going to visit your website has the
            >>>java files on their computers, what you want would not work![/color]
            >>
            >>Before offering javascript advice, one should learn the difference
            >>between java and javascript.
            >>
            >>Before posting to a usenet newsgroup, one should read its FAQ.[/color][/color]
            [color=blue]
            > Oh please pardon me for my typo - I said "java" not "javascript " in my
            > second use of the term.[/color]

            If you consider java a typo for javascript..... ....

            javasrcipt is a typo, java instead of javascript is not.
            [color=blue]
            >Do you disagree with the substance of my post?[/color]

            Since you talked about "java files", and the question was about
            javascript then yeah I disagree with you. As for changing it to
            javascript instead of java, then I still disagree with the "substance"
            because it offers no solution to the problem, not even close.
            [color=blue]
            >Is there a word for shits like you who go around trying to prove their
            > superiority by picking on typos in other peoples posts? I've been
            > programming for 15 years thanks very much.[/color]

            You have been programming 15 years and don't know the difference between
            java and javascript? (other than to try to pass it off as a typo?).
            [color=blue]
            >I'm trying to help someone, what are you doing you miserable maggot?[/color]

            Correcting incompetent, unknowledgable idiots like you.

            --
            Randy
            Chance Favors The Prepared Mind
            comp.lang.javas cript FAQ - http://jibbering.com/faq/

            Comment

            • gendem

              #21
              Re: Javascript equivalent of #include or @import?

              Hi Simon

              The scripting I do has no server; Adobe has implemeneted javascript as
              a cross-platform scripting language to control Photoshop CS, it works
              in much the same way as vb and applescript do in this case. There is
              no server, no browser, nothing to do with the web at all, sorry if I
              wasn't clear.

              SSI and the other techniques work for web pages, but not for anything
              else. The lack of an equivalent command to use/require in perl or
              #include in C is what I'm looking for, and from the sounds of it, that
              doesn't exist.

              Thanks anyway
              [color=blue]
              > To load any file into the current page from the server use :
              ><!--#include file="[filename]"-->This is server side code.Javascript runs on
              >the client so unless everyone who is going to visit your website has the
              >java files on their computers, what you want would not work!
              >"gendem" <gendem@yahoo.c om> wrote in message
              >news:in4h00he9 ilt5navjh6hvcdu d0lt6jea7u@4ax. com...[color=green][color=darkred]
              >> >>> I'm wondering if there's a way to include other pieces of javascript
              >> >>> code from *within* javascript.... a la #include in C, @import in Java,
              >> >>> use/require in Perl, include()/require() in PHP, etc....
              >> >>
              >> >> Not in general, no. If you want to include it while the page is being
              >> >> loaded, you can use document.write to write a new Javascript tag:[/color]
              >>
              >> Rats. I'm trying to script in PhotoShop, which uses Javascript, and
              >> it sure is a waste to have to copy code around instead of just
              >> including it. I guess it's a limitation of not seeing all potential
              >> uses of a language before hand. Oh well.[/color]
              >[/color]

              Comment

              • gendem

                #22
                Re: Javascript equivalent of #include or @import?

                Jeez Randy, lighten up.

                On Sat, 24 Jan 2004 19:09:50 -0500, Randy Webb
                <hikksnotathome @aol.com> wrote:
                [color=blue]
                >Simon Wigzell wrote:
                >[color=green]
                >> To load any file into the current page from the server use :
                >> <!--#include file="[filename]"-->This is server side code.Javascript runs on
                >> the client so unless everyone who is going to visit your website has the
                >> java files on their computers, what you want would not work![/color]
                >
                >Before offering javascript advice, one should learn the difference
                >between java and javascript.
                >
                >Before posting to a usenet newsgroup, one should read its FAQ.[/color]

                Comment

                • Lasse Reichstein Nielsen

                  #23
                  Re: Javascript equivalent of #include or @import?

                  gendem <gendem@yahoo.c om> writes:
                  [color=blue]
                  > The scripting I do has no server; Adobe has implemeneted javascript as
                  > a cross-platform scripting language to control Photoshop CS, it works
                  > in much the same way as vb and applescript do in this case. There is
                  > no server, no browser, nothing to do with the web at all, sorry if I
                  > wasn't clear.[/color]

                  Ah, yes. The power of a completely abstract language ...
                  [color=blue]
                  > SSI and the other techniques work for web pages, but not for anything
                  > else. The lack of an equivalent command to use/require in perl or
                  > #include in C is what I'm looking for, and from the sounds of it, that
                  > doesn't exist.[/color]

                  .... along with the penalties for not assuming anything about the
                  context it runs in. Since ECMAScript is completely agnostic about the
                  environment it runs in, it can't have an include method build in. That
                  would require making assumptions about, e.g., files and directories,
                  in order to work.

                  So, it must be the job of the host environment to make include options
                  available. Browsers haven't typically done that in Javascript itself,
                  because it is possible to go throug HTML or the DOM. In your case, you
                  don't have that possibility.

                  If they try to make documents self-contained, then it won't make sense
                  to allow dynamic includes of external scripts. Then your document
                  wouldn't work if mailed to someone else, unless you also include the
                  external file. For, e.g., PDF, that would be a problem. So, maybe
                  there is no way, but you should ask some Adobe specialists, because it
                  is not a general Javascript problem.
                  /L
                  --
                  Lasse Reichstein Nielsen - lrn@hotpop.com
                  DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
                  'Faith without judgement merely degrades the spirit divine.'

                  Comment

                  Working...