how can i switch web pages of the website automatically , which i have created, using javascript?

Sandy

I want to create website which will mostly look like a presentation with no user input.The user must vist to my site and he will be able to see images sliding and after regular interval of time the page must change automatically. I want to know how can i switch pages of my website using javascript at regular interval of time.

Mark Vayngrib

Here's a way to do it in one page. Essentially, every TIME_PER_PAGE interval, you switch the "page" div out, and sub in the next page. The inline stylesheet ensures that only the current page is visible and that it takes up the full size of the screen.

    <html>
    <head>
        <style>
            body, html { 
                height: 100%; 
                overflow: hidden; 
                padding: 0; 
                margin: 0; 
            }

            .page {
              top: 0; 
              left: 0; 
              width: 100%; 
              min-height: 100%; 
              position: absolute; 
              display: none; 
              overflow: hidden;
              border: 0;
            }

            .currentPage { 
              display: block; 
            }
        </style>
    </head>
    <body>
        <script>
            var TIME_PER_PAGE = 2000;
            window.onload = function() {
                var pages = document.querySelectorAll('.page'),
                    numPages = pages ? pages.length : 0;
                    i = -1;

                function nextPage() {
                    if (i >= 0)
                        pages[i].classList.remove('currentPage');

                    i++;
                    pages[i].classList.add('currentPage');
                    if (i < numPages - 1)
                      setTimeout(nextPage, TIME_PER_PAGE);
                }

                nextPage();
            }
        </script>

        <div class="page">Page 1 Content</div>
        <div class="page">Page 2 Content</div>
        <div class="page">Page 3 Content</div>
        <div class="page">Page 4 Content</div>
        <div class="page">Page 5 Content</div>
    </body>
    </html>

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Why do two web pages have different localStorage? How can I fix this?

来自分类Dev

How can I have mocha reporter for protractor?

来自分类Dev

How can I automatically silence my computer at night?

来自分类Dev

I can only make a cookie have one value in javascript

来自分类Dev

I have a few function overloads, each of which takes a different subclass; how do I check which function to use for a given object?

来自分类Dev

How can I return an anonymous object in Javascript?

来自分类Dev

How can I select the item that doesn't have attribute

来自分类Dev

Can I create a class which can be unpacked?

来自分类Dev

Can I created date property if user not send?

来自分类Dev

Can I use the atto editor for my website?

来自分类Dev

How can I use google web fonts with phantomjs

来自分类Dev

How can I find my browser web log file?

来自分类Dev

How can I create a web application using Angular frontend and Node backend and Git hub API starting from OAuth?

来自分类Dev

How can I set up a WiFi-hotspot to host files which can be downloaded by an other device later

来自分类Dev

How do I add a Web URL to a document using LotusScript

来自分类Dev

How can I backup all my Google Photos / Google Drive automatically on linux?

来自分类Dev

I have javascript function that add numbers to array

来自分类Dev

How can I convert this complicated date format to this in javascript

来自分类Dev

How can I add more button on my Android application which already includes a scrollview?

来自分类Dev

How can I get the current weekday in Rust using the Chrono crate?

来自分类Dev

How can I center text inside a div element using CSS

来自分类Dev

How can I create a temporary table using PetaPoco?

来自分类Dev

How can I send a string as NULL to SQLServer using Dapper?

来自分类Dev

Using Gradle, how can I ensure that a file exists at a certain location?

来自分类Dev

How can I connect to a postgreSQL database into Apache Spark using scala?

来自分类Dev

How can I get last inserted id using Hibernate

来自分类Dev

How can I stop controls from using a KeyEvent?

来自分类Dev

How can I allow location access using Selenium?

来自分类Dev

How can I change a word in a buffer using elisp?

Related 相关文章

  1. 1

    Why do two web pages have different localStorage? How can I fix this?

  2. 2

    How can I have mocha reporter for protractor?

  3. 3

    How can I automatically silence my computer at night?

  4. 4

    I can only make a cookie have one value in javascript

  5. 5

    I have a few function overloads, each of which takes a different subclass; how do I check which function to use for a given object?

  6. 6

    How can I return an anonymous object in Javascript?

  7. 7

    How can I select the item that doesn't have attribute

  8. 8

    Can I create a class which can be unpacked?

  9. 9

    Can I created date property if user not send?

  10. 10

    Can I use the atto editor for my website?

  11. 11

    How can I use google web fonts with phantomjs

  12. 12

    How can I find my browser web log file?

  13. 13

    How can I create a web application using Angular frontend and Node backend and Git hub API starting from OAuth?

  14. 14

    How can I set up a WiFi-hotspot to host files which can be downloaded by an other device later

  15. 15

    How do I add a Web URL to a document using LotusScript

  16. 16

    How can I backup all my Google Photos / Google Drive automatically on linux?

  17. 17

    I have javascript function that add numbers to array

  18. 18

    How can I convert this complicated date format to this in javascript

  19. 19

    How can I add more button on my Android application which already includes a scrollview?

  20. 20

    How can I get the current weekday in Rust using the Chrono crate?

  21. 21

    How can I center text inside a div element using CSS

  22. 22

    How can I create a temporary table using PetaPoco?

  23. 23

    How can I send a string as NULL to SQLServer using Dapper?

  24. 24

    Using Gradle, how can I ensure that a file exists at a certain location?

  25. 25

    How can I connect to a postgreSQL database into Apache Spark using scala?

  26. 26

    How can I get last inserted id using Hibernate

  27. 27

    How can I stop controls from using a KeyEvent?

  28. 28

    How can I allow location access using Selenium?

  29. 29

    How can I change a word in a buffer using elisp?

热门标签

归档