inherit
180698
0
Apr 24, 2013 22:25:44 GMT -8
marona
37
June 2012
marona
|
Post by marona on Apr 14, 2013 13:38:20 GMT -8
I have a set of javascript code that changes the background based on the time of day of the user's computer. It's not working in the Forum Wrapper but works on javascript test websites. I'm assuming it has to do with where I'm putting it but I could be wrong. Help?
<script> var currentTime = new Date().getHours(); if (7 <= currentTime && currentTime < 20) { if (document.body) { document.body.background = "https://imageshack.us/a/img834/8088/skywip.png"; } } else { if (document.body) { document.body.background = "http://i.imgur.com/om9Wt5z.jpg?2"; } } </script>
|
|
inherit
58740
0
Aug 20, 2024 7:29:21 GMT -8
®i©hie
I'm not very active here anymore thanks to my full-time job. - 12/27/23
14,036
September 2005
soe
|
Post by ®i©hie on Apr 17, 2013 12:17:21 GMT -8
I have a set of javascript code that changes the background based on the time of day of the user's computer. It's not working in the Forum Wrapper but works on javascript test websites. I'm assuming it has to do with where I'm putting it but I could be wrong. Help?
<script> var currentTime = new Date().getHours(); if (7 <= currentTime && currentTime < 20) { if (document.body) { document.body.background = "https://imageshack.us/a/img834/8088/skywip.png"; } } else { if (document.body) { document.body.background = "http://i.imgur.com/om9Wt5z.jpg?2"; } } </script>
make sure it's somewhere in between the body tags (<body> & </body>). i've rehosted the imageshack saved pic, try this: <script type="text/javascript"> <!-- if(document.body){ var currentTime=new Date().getHours(); if(7 <= currentTime && currentTime < 20){ document.body.background="http://i.imgur.com/sKE9qu6.jpg"; }else{ document.body.background="http://i.imgur.com/om9Wt5z.jpg"; }} // --> </script>
|
|
inherit
180698
0
Apr 24, 2013 22:25:44 GMT -8
marona
37
June 2012
marona
|
Post by marona on Apr 18, 2013 17:45:21 GMT -8
Yeah I made sure it was right before the closing body tag, removed my image and made the default bg image transparent and still nothing...
|
|
inherit
58740
0
Aug 20, 2024 7:29:21 GMT -8
®i©hie
I'm not very active here anymore thanks to my full-time job. - 12/27/23
14,036
September 2005
soe
|
Post by ®i©hie on Apr 19, 2013 10:54:31 GMT -8
Yeah I made sure it was right before the closing body tag, removed my image and made the default bg image transparent and still nothing...
url of the forum? i don't see why it wouldn't work?
|
|
inherit
180698
0
Apr 24, 2013 22:25:44 GMT -8
marona
37
June 2012
marona
|
Post by marona on Apr 19, 2013 13:02:28 GMT -8
|
|
inherit
58740
0
Aug 20, 2024 7:29:21 GMT -8
®i©hie
I'm not very active here anymore thanks to my full-time job. - 12/27/23
14,036
September 2005
soe
|
Post by ®i©hie on Apr 19, 2013 13:22:58 GMT -8
can you disable guests must login, so i can see it?
|
|
inherit
180698
0
Apr 24, 2013 22:25:44 GMT -8
marona
37
June 2012
marona
|
Post by marona on Apr 19, 2013 14:29:01 GMT -8
Oh yeah I was gonna do that. Sorry I forgot while working on other forums. Hehe. Disabled!
|
|
inherit
58740
0
Aug 20, 2024 7:29:21 GMT -8
®i©hie
I'm not very active here anymore thanks to my full-time job. - 12/27/23
14,036
September 2005
soe
|
Post by ®i©hie on Apr 20, 2013 11:54:35 GMT -8
Oh yeah I was gonna do that. Sorry I forgot while working on other forums. Hehe. Disabled!
i found a work-around that worked when tested on my forum, try this: <script type="text/javascript"> <!-- if(document.body){ var currentTime=new Date().getHours(); if(7 <= currentTime && currentTime < 20){ document.body.style.cssText="background-image:url(http://i.imgur.com/sKE9qu6.jpg);"; }else{ document.body.style.cssText="background-image:url(http://i.imgur.com/om9Wt5z.jpg);"; }} // --> </script>
|
|
inherit
180698
0
Apr 24, 2013 22:25:44 GMT -8
marona
37
June 2012
marona
|
Post by marona on Apr 20, 2013 12:21:03 GMT -8
Yes!! This is perfect. Thank you so much :3
|
|
inherit
58740
0
Aug 20, 2024 7:29:21 GMT -8
®i©hie
I'm not very active here anymore thanks to my full-time job. - 12/27/23
14,036
September 2005
soe
|
Post by ®i©hie on Apr 20, 2013 12:22:34 GMT -8
Yes!! This is perfect. Thank you so much :3
You're Welcome!
|
|