简体   繁体   中英

how to share data between two html pages on a local network?

i want to send a few variables from a html page on one device to another hmtl page on a different device but on the same local network to be displayed immediately. Im not well versed with servers and i want to know how i can do this

It is not possible to do this in HTML.

This all depends on what backend system you are using. A you would need to get the backend system or a listener to relay the information to another device.

Here is a method of sharing information between two HTML pages, using HTML and JavaScript only.

1. Send Request Paramaters

http://example.com/page?parameter1=value&parameter2=value

2. Extracting data received from the URL in the page

<script language="JavaScript">
  function processUser()
  {
    var parameters = location.search.substring(1).split("&");

    var temp = parameters[0].split("=");
    l = unescape(temp[1]);
    temp = parameters[1].split("=");
    p = unescape(temp[1]);
    document.getElementById("parameter1").innerHTML = l;
    document.getElementById("parameter2").innerHTML = p;
  }
</script>

3.Updating the page with data received

    document.getElementById("parameter1").innerHTML = l;
    document.getElementById("parameter2").innerHTML = p;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM