View Full Version : Help me to develop this code
agungbudiono
10-07-2016, 02:21 PM
I have css code that placed above </body>
I want this, to show on my blog only 12 hour per day (or I can set the time), also with cookie
<style type='text/css'>
#trblack{padding-left:240px;filter:alpha(opacity=60);opacity:.0;position:fixed;_position:absolute;top:20px;left:0;z-index:10;clip:inherit;_top:expression(document.documentElement.scrollTop+document.documentElement.clientHeight-this.clientHeight);_left:expression(document.documentElement.scrollLeft+document.documentElement.clientWidth - offsetWidth)}
#samping {padding-left:280px;}
</style>
Expert please help
jscheuer1
10-07-2016, 04:36 PM
You cannot set or evaluate time or a cookie with css. Javascript or some sort of server side code would be workable. In terms of reliability, server side code is best (results seen by all), next comes javascript (results seen only by those with javascript enabled), next cookie (though a cookie can be set and evaluated server side as well as with javascript, people can refuse, delete, or modify them on their own). What would the cookie do? Setting the time of day in either javascript or server side code would be easier and more reliable.
Depending upon how mission critical this is, I would go for javascript. On a blog, that's usually available while server side code often is not an option. Also, I get the feeling you want to do this as a sort of daylight/night time sort of thing, have things darker at night - is that it? If so, javascript would be fine, because the few people without it would just see the normal page. And with javascript it's easy to get the user's time, which might make more sense. But if you want the time to be relative to a specific location that can be more or less worked out as well. On the server side it's difficult to get the user's time.
What's the purpose for this? Is it like I guessed, to give a different look at night?
agungbudiono
10-07-2016, 10:49 PM
You right, can you convert this code to javascript
jscheuer1
10-08-2016, 03:34 AM
Well, I see it's already using javascript in an indirect way - the IE 9 and less proprietary 'expression' css syntax relies upon a no longer used by any browser technique that used javascript to calculate css values on the fly. It was very effective in it's time, but is now discontinued. What browser(s) are you testing in? What browser(s) are you targeting? I would recommend forgetting about IE 9 and less, and using modern standards. But if there's some reason that's not workable for you, let me know,
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.