I have a javascript file which creates a button using innerHTML
like
div = document.createElement('div');
div.innerHTML="<input type='button' value='Login' />";
this is demo.js
Now I want to call a method say hello() which is in some other javascript file say hello.js
e.g,
var objHello = {
sayHello: function() {
alert("Hello World");
}
};
I have to run this demo.js using GreaseMonkey4IE on IE,
Right now it successfully creates the button but the problem is to call sayHello() method of hello.js (because it is an external file).
In html we can simply use <Script> tag using src="jsName" but I have no idea how to do it here.
All script files imported into the page are loaded into the same scope. Just be sure that any code that runs inline has what needs loaded before it executes.
var objGreeting = {
Greetings : function() {
toolbardiv = document.createElement('toolbardiv'); // create div tag dynamically
toolbardiv.setAttribute('id',"toolbar"); // give id to it
toolbardiv.className="top"; // set the style classname
//set the inner styling of the div tag
toolbardiv.style.position="absolute";
//set the html content inside the div tag
toolbardiv.innerHTML="<input id='Greeting-Button' type='greet' value='Login' onClick='objHello.SayHello()'/>"
}
},
var objHello = {
SayHello: function() {
alert("Hello World");
}
};
Right now this all is in a single JS file and it's working fine.
Now I want to separate the two classes above into two different js files.
But after doing this I am not able to call the SayHello method.
I am using "GreaseMonkey for IE" and IE8 to run this script.
"It's good to B in touch...So keep responding"
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.