简体   繁体   中英

How to load this JavaScript when page Loaded

I'm a newbie to programming and I want to ask something about Javascript.

How to make this script is displayed when the page is loaded?

I want to make "1 people online" with this jQuery pop up.

$(document).ready(function() {
     $.sticky('1 user seen this hotel!');
 });

Can you all tell me how to use it and how to modify it?

I get this function from http://www.jqueryrain.com/?uOBwr_rL

Please help me.

Thanks, gbu

If you don't need the sticky functionality (ie if it's okay for a user to close the window), you can use an alert:

$(document).ready(function() {
     alert('1 user seen this hotel!');
});

Or the jquery dialog: http://jqueryui.com/dialog/

Sample HTML Page

<html>
  <head>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
    <script type="text/javascript" src="sticky.min.js"></script>
    <link rel="stylesheet" href="sticky.min.css" type="text/css" />
  </head>
  <body>

    <script type="text/javascript">
       $(document).ready(function() {
             $.sticky('The page has loaded!');
           });
    </script>
  </body>
</html>

Please make sure you save this html content as HTML page in the same directory as your sticky.min.js & sticky.min.css files.

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