Open HTML page
I have a .html file (X) that depending on some value should immediately open another .html file (Y) when opening a .html file (X). What's the best way to implement this in javascript?
Also, I want the user to click the "Refresh (F5)" button on the Y.html page that needs to be loaded again so that the one that started the current (X).
source to share
I have a .html file (X) that depending on some one immediately open another .html file (Y) when I open a .html file (X). What's the best way to implement this in javascript?
You can do this using window.open .
Also I want that when the user clicks 'Refresh (F5)' on the Y.html page which has to be loaded again to be which the current (X) started.
You can do this in the onbeforeunload event of the page (Y) using
window.parent.window.location.href = window.parent.window.location.href;
source to share
Using jQuery might look like:
<input type="text" id="whatPage" value="somepagename">
<input type="button" id="someinput" value="getPage">
<div id="targetDiv">
I will be filled with the resulting HTML.
</div>
<script>
$('#someinput').click(function() {
$.ajax({
url: $('#whatPage').val()+'.htm',
success: function(response) {
$('#targetDiv').html(response);
}
});
});
</script>
source to share