Suppose the site has 4 pages:

  • page.html (here 2 links <a> that lead to another page - example.html)
  • example.html (blank page)
  • result1.html
  • result2.html

How to make it so that when you click on the first link, the example.html page opens with the contents of result1.html ? Accordingly, when you click on the second link, example.html also opens, but the contents of result2.html loaded into it.

As far as I understand, it’s necessary to transmit some value by reference, and to make a check on a blank page: if the value is one, then we show the contents of result1.html , if the other is the result2.html . Tell me how you can accomplish this and using what (JS, PHP or standard HTML tools)?

Thank you very much in advance.

    2 answers 2

    Well, if you just give a hint, and not write code, I’ll tell you about JS options:

    A variant:

    1 - when hovering the cursor over the necessary link (onmousemove event), write in the cooler (coockies) to do this (this depends on the link over which the cursor is now)

    2 - in the example.html code for the onload event or at the very beginning of the page, hang up a code that reads the cookie and, depending on what is written there, performs the necessary action

    B option

    1 - In the required link in the href parameter, besides the link itself, add GET parameters

    2 - .. and catch them in example.html and depending on the fact that in the parameters to perform the appropriate actions

    C option

    use local storage from HTML5 actions will be similar to A variant

    PS

    but in general you should find out how to transfer data between pages on JS

    • Yes, the ways of the sea - RusArt
    • I do not need the code, I myself want to understand the options for implementation. Thank you very much, I will dig in these directions. - Win_D

    It is possible in PHP.

    To the link to example.php add the GET request example.php?page=1 or example.php?page=2

    The code in example.php will be something like this:

     <?php if ($_GET['page'] == 1) readfile("result1.html"); if ($_GET['page'] == 2) readfile("result2.html"); ?>