0

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

2
  • Could you explain why you are doing something like this? Commented May 4, 2009 at 12:54
  • Indeed, I'll answer, but it might be useful to explain what the value is that you are speaking of is, or at least what category of input we are talking about. Is this a user input? Commented May 4, 2009 at 12:58

3 Answers 3

1

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;
Sign up to request clarification or add additional context in comments.

Comments

0

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>

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.