• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Define a JS object please help

 
Nicholas Turner
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my main html file has
<html>
<head>
<SCRIPT LANGUAGE="JavaScript1.2" SRC="c:\MainMenu.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.2" SRC="c:\menuItem.js"></SCRIPT>
<SCRIPT language="JavaScript1.2">
<!--
function loadMenus() {
window.spiritMenu = new MainMenu();
...
and the mainmenu.js file has
function MainMenu() {
this.description = "";
//if( parentMenu != null )
//this.parent = parentMenu;
this.toolTip = "";
var menuItems = new Array[0];

}
but it tells me that mainmenu is undefined. what am i doing wrong?
thanks,
nick
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65123
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In

The URL is not valid, so the js file containing the object constructor is not being loaded. If you really want to use a file path to address the file (trust me, you don't), you need to use the file:// protocol format.
I'd highly advise that you move the js files to a web server-addressable location and use an http protocol to address the js file. This can be relative to the server, context or the current file.
hth,
bear
[ June 08, 2003: Message edited by: Bear Bibeault ]
 
Nicholas Turner
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand, this is for testing(prototyping) only. Before I insert it to the web app area
 
Nicholas Turner
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thier located in the same directory. But I changed it and it still doesnt see it.
even when i just say SRC="mainMenu.js"
whats really wrong
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65123
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd say that there's a 99% chance that the 'not defined' error is simply because the js file is not loading. To test this, you can place an alert in the JS file and see if it pops up when the page loads.
hth,
bear
 
Nicholas Turner
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
your right
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic