Import JavaScript within JavaScript


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Import JavaScript within JavaScript

Hybrid View

  1. #1
    Nir Guest

    Import JavaScript within JavaScript


    Hello,

    I'd like to know if there's any way of importing JavaScript file from within
    an HTML page on request from a WebServer through ASP request.
    For example look at the following code :
    <HTML>
    <......
    \....>
    <\HTML>
    <SCRIPT language=JavaScript>
    ....
    onMouseClick = http://server_name?JavaScriptToReturn.asp
    <>

    well the code should be something like that, and I wanna that this imported
    JavaScript file, once
    it's imported, to also be able to serve functionality from within the HTML
    page.

    Thanks in advance,
    Nir.

  2. #2
    Steve Berzins Guest

    Re: Import JavaScript within JavaScript

    Why?

    My first guess is that what you want is to only have to download the script
    to the client once and not again unless it changes, just put the script in a
    ..js file and put a script tag in the <head> section and the browser does
    this all for you automagically.
    <script language="JavaScript" src="somereallybigjavascriptfile.js"></script>
    And all the script in the file is fully accessible from the web page, and
    the script has full access to the web page to do whatever it has to within
    it.

    --
    Steve Berzins, MCSD
    Senior Software Design Engineer
    Shavlik Technologies, LLC MCSPP
    www.shavlik.com
    e.shavlik.com
    steveb@shavlik.com
    "Nir" <nir@effective-i.com> wrote in message
    news:3ab704ac$1@news.devx.com...
    >
    > Hello,
    >
    > I'd like to know if there's any way of importing JavaScript file from

    within
    > an HTML page on request from a WebServer through ASP request.
    > For example look at the following code :
    > <HTML>
    > <......
    > \....>
    > <\HTML>
    > <SCRIPT language=JavaScript>
    > ...
    > onMouseClick = http://server_name?JavaScriptToReturn.asp
    > <>
    >
    > well the code should be something like that, and I wanna that this

    imported
    > JavaScript file, once
    > it's imported, to also be able to serve functionality from within the HTML
    > page.
    >
    > Thanks in advance,
    > Nir.




  3. #3
    Kim Daniel Borch Guest

    Re: Import JavaScript within JavaScript


    This is for IE5 only. The way I read the DOM it should be for NS6 also, but
    I havent been able to make it work - maybe youll have more luck...

    var newScript = document.createElement("SCRIPT"); //create new script object
    newScript.src = "http://server_name?JavaScriptToReturn.asp"; //i dont know
    if this will work - ive only tried with static .js file
    document.body.appendChild(newScript); //insert object in the document hierarchy

    Put that in a function and execute it onclick or whatever suits the purpose.

    Hope this helps although i have my doubts

    Daniel
    No Fancy Business Title
    No Fancy Company Name

    "Nir" <nir@effective-i.com> wrote:
    >
    >Hello,
    >
    >I'd like to know if there's any way of importing JavaScript file from within
    >an HTML page on request from a WebServer through ASP request.
    >For example look at the following code :
    ><HTML>
    ><......
    >\....>
    ><\HTML>
    ><SCRIPT language=JavaScript>
    >....
    >onMouseClick = http://server_name?JavaScriptToReturn.asp
    ><>
    >
    >well the code should be something like that, and I wanna that this imported
    >JavaScript file, once
    >it's imported, to also be able to serve functionality from within the HTML
    >page.
    >
    >Thanks in advance,
    >Nir.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center