...

View Full Version : Oncepersession floating div



mihai1
01-10-2012, 09:16 AM
Hello all from Romania, I tried few hours yesterday to edit the javascript settings because I want to be displayed once per session.

If you can help me, or edit because I know it's very simple but for me... isn't the same thing.

This is the code I want to be displayed once per session, and IF you can to close after x seconds, but important is once per session.


<style>
#topbar {
height:30px;
width:auto;
background: #005094 url('http://lh3.ggpht.com/_beEpWOXwLJE/TIb57Lu4fwI/AAAAAAAABE0/q7niFVRbyNE/top-toolbar.jpg');
background-repeat:repeat-x;
text-align:left;
padding-top:4px;
}
#adsground {
height:auto;
margin:0 auto;
width: 310px;
background:#fff;
border-bottom:2px #005094 solid;
border-right:2px #005094 solid;
border-left:2px #005094 solid;
text-align:Center;
padding:4px;
}


#headlineatas {
margin-left:85px;
opacity:1.0;
height:auto;
width:auto;
position:fixed;
top:65px;
left:170px;
border-bottom:1px #005094 solid;
border-bottom:0px blue solid;
color:#333;
padding:0px;
z-index:1001;
font-size:13px;}
</style>


<script type="text/javascript">
function getValue()
{
document.getElementById("headlineatas").style.display = 'none';
}
</script>


<div id="headlineatas">
<div id="topbar">

<span style="color:#fff;font-size:13px;font-wegight:bold;text-shadow:black 0.1em 0.1em 0.1em">Asculti AlyceRadio.</span>
<span style="color:#fff;font-size:13px;font-weight:bold;text-shadow:black 0.1em 0.1em 0.1em;float:right;padding-top:3px;padding-right:10px"><a href="http://www.google.ro/" target="_blank" onclick="getValue()">X</a></span>
</div>
<div id="adsground">
<p align="left"><h3></h3></p>

another text here

<p>

</p></div></div>

Thanks !

Philip M
01-10-2012, 10:55 AM
Have you tried using the search feature of this forum?
I am unclear what it is you want to show only once per session, but here is something for you to study and adapt:-


<html>
<head>
<script type = "text/javascript">

//Alert only once per browser session (0=no, 1=yes)
var once_per_session=1;

function get_cookie(Name) {
var search = Name + "=";
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search);
if (offset != -1) { // if cookie exists
offset += search.length;
// set index of beginning of value
end = document.cookie.indexOf(";", offset);
// set index of end of cookie value
if (end == -1);
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function alertornot(){
if (get_cookie('alerted')==''){
loadalert();
document.cookie="alerted=yes";
}
}

function loadalert(){
var alertmessage = "This message will show only once per browser session";
alert(alertmessage);
document.getElementById("message").innerHTML = alertmessage;
}

function start() {
if (once_per_session==0){loadalert()}
else {alertornot()}
}

</script>

</head>
<body onload = "start()">

<div id = "message"></div>

</body>
</html>

To show the contents of a <div> for so many seconds, then hide:-


<body onload = "timer()">

<div id = "mydiv1" style="display:block">
SOME STUFF IN HERE
</div>

<script type = "text/javascript">
var count = 0;
function timer() {
count ++;
if (count >= 10) {
document.getElementById("mydiv1").style.display="none";
}
else {
setTimeout(timer,1000);
}

}
</script>

Remember that you may not have multiple onload statements. You need to do it thus:-


<script type="text/javascript">
window.onload = function() {
functionOne();
functionTwo();
}
</script>

or


<body onload="functionOne();functionTwo()">

mihai1
01-10-2012, 11:08 AM
Hello again, my desire is to make this floating div ( see the first post) to be displayed only once per browser session or 24 hours.

Something like that, but I don't know how to implement in my script from first post of this topic. I know is a short script code to add in my script but I don't know how...

[QUOTE]//Specify display mode. 3 possible values are:
//1) "always"- This makes the fade-in box load each time the page is displayed
//2) "oncepersession"- This uses cookies to display the fade-in box only once per browser session
//3) integer (ie: 5)- Finally, you can specify an integer to display the box randomly via a frequency of 1/integer...
// For example, 2 would display the box about (1/2) 50% of the time the page loads.

var displaymode="always"

Philip M
01-10-2012, 11:21 AM
Hello again, my desire is to make this floating div ( see the first post) to be displayed only once per browser session or 24 hours.

Something like that, but I don't know how to implement in my script from first post of this topic. I know is a short script code to add in my script but I don't know how...

//Specify display mode. 3 possible values are:
//1) "always"- This makes the fade-in box load each time the page is displayed
//2) "oncepersession"- This uses cookies to display the fade-in box only once per browser session
//3) integer (ie: 5)- Finally, you can specify an integer to display the box randomly via a frequency of 1/integer...
// For example, 2 would display the box about (1/2) 50% of the time the page loads.

var displaymode="always"

I do not see anything resembling that code in your first post. Are you trying to add some more code from another source to your existing?
Make up your mind - display once per browser session, or once per 24 hours? Which?

mihai1
01-10-2012, 11:41 AM
I do not see anything resembling that code in your first post. Are you trying to add some more code from another source to your existing?
Make up your mind - display once per browser session, or once per 24 hours? Which?


Display once per borwser session I want. And yes I tried to move from another (source) some java script code for floating div, but not working so I asked for help here.

If you want to add in first post code some javascript "lines" to help me in this issue.

Thank you for implication :D

Philip M
01-10-2012, 11:49 AM
I posted the necessary code in Post #2, but it is more than "a few" lines. I assume that you can adapt and incorporate it in your existing code. If that is not correct, then all I can suggest is to learn Javascript.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum