How to make an element appear on another html page after clicking on the first page button?

  • 0
    For example Click me
    $ ("p"). click (function () {
    alert ("Clicked");
    I don’t know how to show this notification on another page. You can show this example without notification.
    JavaScript Anonymous, Apr 21, 2019

  • 2 Answers
  • 0
    This can be done directly if two conditions are met:

    1. Both pages belong to the same site.

    2. The second page was opened by the first

    Are these conditions met?

  • 0
    Use BroadcastChannel

    The BroadcastChannel interface is a named channel that you can subscribe to from any viewing context for a given source. This allows you to set up communication between different documents (in different windows, tabs, frames, etc.) of the same source. Messages are propagated using the message event, which fires for all BroadcastChannel objects listening on that channel.

    Here's an example

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!