views:

88

answers:

3

I have an .html file (X) that depending on some value should immediately open another .html file (Y) when opening the .html file (X). What's the best way to implement this within javascript?

Also I want that when the user presses 'Refresh (F5)' on Y .html the page that should be loaded again to be the one that started the current one (X).

+1  A: 

I have an .html file (X) that depending on some value should immediately open another .html file (Y) when opening the .html file (X). What's the best way to implement this within javascript?

You can do this using window.open.

Also I want that when the user presses 'Refresh (F5)' on Y .html the page that should be loaded again to be the one that started the current one (X).

You can do this in the onbeforeunload event of page (Y) using

window.parent.window.location.href = window.parent.window.location.href;
Kirtan
A: 

Using jQuery it might look like this:

<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>
altCognito
A: 

The nice thing to do will be ajax. Loading by javascript in some main div the content of Y. Some info here.

The easy option will be to use frames. First loading a frame X and then according to the value loading and resizing a second frame Y. Some info here.

Lucas