Click here to Skip to main content
15,905,420 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this javascript code satisfied random background image for every link.. but images sometimes full screen sometimes middle on the screen because some pages footer go down some pages footer finish middle of the screen so some image full some image middle seems

how to change this javascript code for full screen page regardless

XML
<script type="text/javascript">
      var loading = function () {
          var totalCount = 6;
          var num = Math.floor(Math.random() * totalCount) + 1;

          document.body.background = 'images/' + num + '.jpg'
          document.body.style.backgroundRepeat = "no-repeat";

            document.body.style.backgroundSize = "cover";
//          document.body.style.backgroundSize = "100% 1920px";




      }

    </script>

</head>
<%--<body>--%>
<body onload='loading();'>


maybe I will change css but I want to try to change javascript
Posted
Comments
Sergey Alexandrovich Kryukov 7-May-14 9:03am    
Each image cannot fill the screen because 1) images have different aspect ratio; 2) the browser window itself does not take full screen, it takes the size chosen by the user. You need to describe desired behavior exactly.
—SA
Peter Leow 7-May-14 9:53am    
You are right. Thanks.
Sergey Alexandrovich Kryukov 7-May-14 11:26am    
Thank you for understanding. If OP provides exact description of all layouts or the clear idea of them, we probably will be able to help.
—SA
Prasad Avunoori 8-May-14 0:17am    
Are all images of same size? If not it's difficult to show full.
Make sure are images are of same size.
Member-2338430 8-May-14 8:21am    
all images same size only pages different height so height droping image

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900