how to link one javascript to another javascript code example

Example 1: javascript redirect

window.location.href = "http://mywebsite.com/home.html";

Example 2: javascript link to another page

window.open("http://mywebsite.com/home.html")

Example 3: how to call a script from another script in javascript

<script type="text/javascript" src="file1.js"></script>
<script type="text/javascript" src="file2.js"></script>
<script type="text/javascript">
    alertOne( );
</script>

Example 4: how to call a script from another script in javascript

// File1.js
function alertNumber( n ) {
    alert( n );
};
// File2.js
function alertOne( ) {
    alertNumber( "one" );
};
// Inline
alertOne( ); // No errors

Tags:

Html Example