Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Oncepersession floating div

    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 !

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,310
    Thanks
    203
    Thanked 2,563 Times in 2,541 Posts
    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:-

    Code:
    <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:-

    Code:
    <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:-

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

    Code:
    <body onload="functionOne();functionTwo()">
    Last edited by Philip M; 01-10-2012 at 12:17 PM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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"

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,310
    Thanks
    203
    Thanked 2,563 Times in 2,541 Posts
    Quote Originally Posted by mihai1 View Post
    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?

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #5
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Philip M View Post
    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

  • #6
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,310
    Thanks
    203
    Thanked 2,563 Times in 2,541 Posts
    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.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • Users who have thanked Philip M for this post:

    mihai1 (01-10-2012)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •