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).

0


source to share


3 answers


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;

      

+1


source


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>

      

0


source


The good thing is ajax. Loading javascript into some main div Y content. Some info here .

An easy option would be to use frames. Load X frame first and then as per load value and resize the second Y frame. Some info here .

0


source







All Articles