calling external .js files from an asp app

Results 1 to 2 of 2

Thread: calling external .js files from an asp app

  1. #1
    Join Date
    Dec 1969

    Default calling external .js files from an asp app

    i have a number of asp files that all need to use the same javascript hierarchical menus. what&#039;s more, each of the javascript hierarchical menus calls upon the the same(much larger) javascript menu object.<BR><BR>i know how to call an external javascript file from my asp pages, but i am encountering problems when i try to separate the code for the javascript menu object from the code for the menu that utilizes the object. specifically, i would like to store one copy of the javascript menu object and then 1 copy of each of a few different javascript menus that utilize the code for the javascript menu object. i think this is clear. if not, please let me know.<BR><BR>my question is:<BR>can i call the .js file that includes the menu object from within the .js file that needs to manipulate the object to create my menu? if so, what does the line of code look like that will call the menuobject.js file from the myinstanceofmenu.js file?<BR><BR>should i instead call both of the .js files from each asp script? if so, what does this need to look like? i am just asking about the 2 lines that call the .js files. what do those 2 lines need to look like?<BR><BR>do i have to keep a duplicate copy of the menu object code in every single myinstanceofmenuobject.js file? this is the lease appealing option, but it is the only option that is working now.<BR><BR>currently, i have:<BR>&#060;script language="JavaScript1.2" src="myinstanceofmenuobject.js"&#062;&#060;/script&#062;<BR><BR>this line calls the .js file which itself contains the complete code for the menu object within it. and the menu works. but when i separate out the menu object from the code that creates my specific instance of the menu, that is when i am generating an error that says "object expected"<BR><BR>your help is much appreciated.<BR>

  2. #2
    Join Date
    Dec 1969

    Default Well, it's not ASP related... all. The .js files *must* be utilized only by the client-side web page. That is, the HTML and whatever JavaScript is included in that HTML.<BR><BR>So the first thing to do is eliminate ASP from the equation.<BR><BR>Bring up the ASP page in your browser. Ignore errors.<BR><BR>Click on the "VIEW" menu of the browser.<BR><BR>Click on the "SOURCE" menu item under View.<BR><BR>Save the HTML page that pops up in your editor (likely Notepad) onto that machine, and then start debugging *just* the HTML and the .js files it includes.<BR><BR>That gets ASP out of the way, and you can concentrate on one thing at a time.<BR><BR>*******************<BR><BR>Having said that...<BR><BR>I do not believe that a .js source file can, in turn, invoke another .js file.<BR><BR>In fact, I&#039;m 90% sure of that.<BR><BR>Because when you are inside a .js file, you *ARE* inside of<BR> &#060;SCRIPT&#062;....&#060;/SCRIPT&#062;<BR>tags, aren&#039;t you?<BR><BR>And the one thing you *CAN NOT DO* from such a file is have an<BR> &#060;/SCRIPT&#062; <BR>tag. And since nested &#060;SCRIPT&#062; tags are illegal...<BR><BR>Well, I think you have your answer.<BR><BR>In short, no.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts