Accessing object in another javascript file -
I have two JS files
Player.js where I create a media
(function () {function media () {this.url = "";} Media.prototype.setURL = function (url) {this.url = url; warning ("setURL =" + this.url) ;}}) ();
Another file is Main.js where I am using this media as shown below
var media = new media (); Main.kidown = function () {var keycode = event.keyCode; Warning ("key pressed:" + keyCode); Switch (keycode) {Case TV. KEY_1: warning ("key pressed 1"); Media.setURL ("1-Link"); break; }};
I have index.html where I have included these scripts
The problem is that I'm having an error reaching this media with the main.js as shown below
[JS error]: File: Main.js line number: 3 Description of error: Reference error: Variable can not be found: Media
I have tried many things, but since I have been on javascript New, until it is unable to resolve
Media
only IIFE Player.js . Remove
(function () {...}) (); Wrapper.
Comments
Post a Comment