I just want my landing screen to be built in normal JavaScript to reduce the load and redirect to my angular 6 app on click of any buttons in landing screen.
How can I redirect from index.html
to another (Angular) index.html
.
I just want my landing screen to be built in normal JavaScript to reduce the load and redirect to my angular 6 app on click of any buttons in landing screen.
How can I redirect from index.html
to another (Angular) index.html
.
Assuming you have multiple buttons on your page, you can trigger a redirect for all the buttons like this:
var buttons= document.getElementsByTagName('button');
for (var i = 0; i < buttons.length; i++) {
var button = buttons[i];
button.onclick = function() {
window.location.href = "https://google.de";
}
}
<button>Button 1</button>
<button>Button 2</button>
<button>Button 3</button>
You can do this by calling the
window.location.replace()
method or updating the value of thewindow.location.href
property.The calling the
window.location.replace()
method simulates a HTTP redirect and updating the value of thewindow.location.href
property simulates a user clicking on a link.You would use them as:
Or:
You could also create a hidden link and trigger a click on it, like this:
If you wanted the link to open in a new tab, you'd use the
target="_blank"
attribute, like this:Good luck.