• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Define a JS object please help

 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
your right
 
Hey! Wanna see my flashlight? It looks like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic