Run Javascripts on Different Pages

Asked 2 years ago, Updated 2 years ago, 47 views

There is a browsing page (index.html) similar to the following

<!doctype html>

<html>
  <head>
    <metacharset="utf-8"/>
    <meta name="viewport" content="width=device-width, user-scalable=no"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>

    <title>Notification</title>
  </head>
  <body>
  <script src='https://cdn.rawgit.com/jaredreich/notie.js/a9e4afbeea979c0e6ee50aaf5cb4ee80e65d225d/notie.js'></script>
  <script>
    window.onload=function(){
      notie.alert(1, 'Notification', 10);
    };
  </script>
  </body>
</html>

The following methods for displaying notifications now run when the page is loaded:
Is it possible to call this from another administrative page (for example, admin.html) at any time?

<script>
    window.onload=function(){
      notie.alert(1, 'Notification', 10);
    };
  </script>

javascript html jquery

2022-09-30 19:16

2 Answers

You can call an iframe referencing index.html at any time.
↓ This image calls the following functions at any time.

function call_it(){
  $("<iframe src='index.html'/>").appendTo("body");
}


2022-09-30 19:16

Roughly speaking,

Admin.html sends a request from admin.html to "notify the user" to the server by some means as user authenticated.

The server maintains a "Need to Notify" state in the above request.

The server pushes the notification to the browser.Really push with WebSocket, pseudo push with HTTP polling, etc.


2022-09-30 19:16

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.