JavaScript making javascript work across two tabs

I'm wanting my javascript file to control two html5 files simultaneously.

<!DOCTYPE html>
<html>
<head>
  <title>tryAgainPage1</title>
  <meta charset="UTF-8">
</head>
<body>

  <div id="page1"></div>

  <script src="tryAgain.js"></script>
</body>
</html>

That's page one. Next is page two.

<!DOCTYPE html>
<html>
<head>
  <title>tryAgainPage2</title>
  <meta charset="UTF-8">
</head>
<body>

  <div id="page2"></div>

  <script src="tryAgain.js"></script>
</body>
</html>

And here is the JavaScript:

newFunction();

function newFunction() {
    document.getElementById("page1").innerHTML = "page one says hello";
    document.getElementById("page2").innerHTML = "page two says goodbye";
}

Page one is working, page two isn't. I've been trying for a day to get pages talking to each other, without success. I'm not sure I understand how to implement Broadcast channel in this instance (if indeed that is appropriate.) Can anyone help?

Answer:1

My html code as below: <div class="formContent"> <label for="title">Data Collection Title:</label><p>Western Australia</p><br/> <...

My html code as below: <div class="formContent"> <label for="title">Data Collection Title:</label><p>Western Australia</p><br/> <...

  1. javascript nested element
  2. js nested element
  3. javascript get nested element
  4. javascript select nested element
  5. javascript get nested element by class
  6. javascript find nested element
  7. javascript get nested element by id
  8. javascript find nested element by class
  9. javascript create nested element
  10. javascript remove nested element
  11. javascript target nested element
  12. javascript find nested element by id
  13. javascript scroll nested element
  14. javascript get nested element by tag
  15. javascript access nested element
  16. javascript nested array element
  17. javascript hide nested element
  18. javascript update nested element
  19. js get nested element
  20. js select nested element

I have been using getUserMedia() for WebRtc for a while now but since the latest update of browsers I have not been able to use this. On previous versions worked fine. Affected browsers' versions ...

I have been using getUserMedia() for WebRtc for a while now but since the latest update of browsers I have not been able to use this. On previous versions worked fine. Affected browsers' versions ...

I have a button that has a drawable XML file set as the background, this is so that when the button is pressed the background colour and outline of the button is change. However it does not stay like ...

I have a button that has a drawable XML file set as the background, this is so that when the button is pressed the background colour and outline of the button is change. However it does not stay like ...

  1. change button state swift
  2. change button state tkinter
  3. change button state javascript
  4. change button state android
  5. change button state unity
  6. change button state arduino
  7. change button state react
  8. change button state
  9. change button state html
  10. change button state java
  11. change button state uibutton
  12. change state button click
  13. unity change button state script
  14. nextion change button state
  15. blynk change button state
  16. android change button state programmatically
  17. jquery change button state
  18. labview change button state
  19. change toggle button state android
  20. change radio button state javascript

when I run npm from terminal I get this error and nothing else. no npm command is working, all of them are giving the same error and I can't even install programs that are depending on nodejs. $ ...

when I run npm from terminal I get this error and nothing else. no npm command is working, all of them are giving the same error and I can't even install programs that are depending on nodejs. $ ...