javascript open html code example

Example 1: how to open html file with javascript

// In my case, I used a button to activate this function:
function myFunction() {
    window.location.href = 'index.html';
}

Example 2: open a html file using js

// In case I don't want any buttons or links to open a document
// I just want to open a document
window.open('file.extension');

Example 3: javascript open new window

<a onclick="window.open(document.URL, '_blank', 'location=yes,height=570,width=520,scrollbars=yes,status=yes');">
Open New Window
</a>