Say I had 2 JavaScript files, f1.js and f2.js respectively and one HTML page called index.html.
I use the script tag to use the code from f1.js in my index.html. But, I want f1.js to use some code from f2.js. So, the hierarchy is like this - index.html <--- f1.js <--- f2.js.
i.e. f2.js is a pseudo-random generator and has a function which creates a random seed, and I want to use this in my code for f1.js.
Code example:
index.html - how I call f1.js in the html page (my code)
<script type="text/javascript" src="f1.js">
</script>
f1.js - my code
function hello() {
Math.seedrandom("1"); // this is the method I want to reuse from f2.js
alert("hello: " + Math.random());
}
f2.js - code I want to use (via the link below)
Math.seedrandom();
How can I do this?
Edit: the file I want to reuse can be found her - http://davidbau.com/encode/seedrandom.js
It's a custom random seed generator tool which has a function: Math.seedrandom("") that I want to use.