SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot Rio's Avatar
    Join Date
    Nov 2001
    Location
    United Kingdom
    Posts
    171
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to show "Disclaimer" page once.

    Hello everyone,

    I am developing a small company information site. One of the pages "Financial Services", for example, has links to 6 - 8 info pages.
    What I want to achieve here is to show a "Disclaimer" page before the viewer get to one of the info pages. Also, I wants to set it up so that the viewers only have to see the "Disclaimer" page the first time they link to info pages.

    Is this kind of thing possible in JavaScript?

  2. #2
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Andrew that link doesn't quite seem to do what he wants.

    I pseudo code here is how I would do it

    User links to page
    javascript checks cookie
    var viewed != 1 (meaning viewed isn;t set and he hasn't seen the disclaimer)
    redirect to disclaimer
    if user agrees
    set variable in cookie viewed=1 (using javascript)
    redirect onto next page

    You can do this check every page and as long as the cookie is set he will not be redirected.
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  4. #4
    I'm NOT an Addict ! TheRock's Avatar
    Join Date
    Jul 2001
    Location
    Earth ... maybe
    Posts
    401
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to show "Disclaimer" page once.

    Originally posted by Rio
    What I want to achieve here is to show a "Disclaimer" page before the viewer get to one of the info pages. Also, I wants to set it up so that the viewers only have to see the "Disclaimer" page the first time they link to info pages.

    Is this kind of thing possible in JavaScript?
    Although this is possible (see earlier replies), since it is a company's site (and legal matters may be in line), I would suggest you to not assume that JavaScript is enabled on all browsers, and rather go with a scheme that displays a small disclaimer on top of each information page and then gives the viewer a link to a full-fledged disclaimer page.

    Just my views.
    -*-
    B-School Forums - GMAT / MBA / Admissions discussions
    -*-

  5. #5
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good point. You could in fact use the saem psuedo code with a server side language. Most of them I believe control cookies. But in any case the easiest way to do this is with cookies and you script reading those cookies to find out if they have been there before or not


    Good point on the javascript
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  6. #6
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why not, just replace the disclaimer with an empty element if javascript is enabled, and allow for a popup.

    that way you get the best of both worlds

    ie

    PHP Code:
    <div id="disclaimer" align="center">
    The opinions of our members and their posts do not reflect the views and opinions of
    SitePoint Pty
    Ltd., its employees or volunteers.
    The SitePoint Community Forums are owned and operated by Sitepoint PtyLtd.
     Copyright 1998-2002SitePoint PtyLtdAll Rights Reserved.
    Powered byvBulletinCopyright 2000-2002Jelsoft Enterprises Limited.
    </
    div>

    <
    script type="text/javascript">
    document.getElementById('disclaimer').innerHTML='';

    // now do disclaimer in popup
    </script> 

  7. #7
    SitePoint Zealot Rio's Avatar
    Join Date
    Nov 2001
    Location
    United Kingdom
    Posts
    171
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi guys, I'm back again. Thanks for the inputs

    After talking to my client, it seems like Maelstrom's scheme plus inserting a link within pages will be the best option in this case.

    The trouble here is I'm a javascript newby and not sure how to write it from scratch. Can anyone know a good script for this job or where to look up?? Once I got the basic script think I can change the details.

  8. #8
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You might be able to incorporate this somehow...sorry I don't have the time right now to whip up a cookie code. Andrew will probably have one lying around though.

    http://www.hotscripts.com/JavaScript...grams/Cookies/
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  9. #9
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hehe, Maelstrom. To be honest i don't really use cookies often so i havent gotten round to making my own script, but i edited this one and it works just fine. I'm gonna have to make a few now.

    PHP Code:
    <script type="text/javascript">

        
    url  'http://www.google.com';
        
    opts '';

        function 
    getCookieVal (offset)
        {
            var 
    endstr document.cookie.indexOf (";"offset);
            if (
    endstr == -1endstr document.cookie.length;
            return 
    unescape(document.cookie.substring(offsetendstr));
        }

        function 
    GetCookie (name)
        {
            var 
    arg name "=";
            var 
    alen arg.length;
            var 
    clen document.cookie.length;
            var 
    0;
            
            while (
    clen)
            {
                var 
    alen;
                
                if (
    document.cookie.substring(ij) == arg) return getCookieVal (j);
                
    document.cookie.indexOf(" "i) + 1;
                if (
    == 0) break;
            }
            return 
    null;
        }

        function 
    SetCookie (namevalue)
        {
            var 
    argv SetCookie.arguments;
            var 
    argc SetCookie.arguments.length;
            var 
    expires = (argc) ? argv[2] : null;
            var 
    path = (argc) ? argv[3] : null;
            var 
    domain = (argc) ? argv[4] : null;
            var 
    secure = (argc) ? argv[5] : false;
            
    document.cookie name "=" escape (value) +((expires == null) ? "" : ("; expires=" expires.toGMTString())) +((path == null) ? "" : ("; path=" path)) +((domain == null) ? "" : ("; domain=" domain)) +((secure == true) ? "; secure" "");
        }

        function 
    DisplayInfo()
        {
            var 
    expdate = new Date();
            var 
    visit;
            
    expdate.setTime(expdate.getTime() +  (24 60 60 1000 365)); 
            
            if(!(
    visit GetCookie("visit"))) visit 0;
            
    visit++;
            
    SetCookie("visit"visitexpdate"/"nullfalse);
            var 
    message;

            if (
    visit <= 1window.open(url,'',opts);
        }

        function 
    ResetCounts()
        {
            var 
    expdate = new Date();
            
    expdate.setTime(expdate.getTime() +  (24 60 60 1000 365)); 
            
    visit 0;
            
    SetCookie("visit"visitexpdate "/"nullfalse);
            
    history.go(0);
        }

        
    window.onload=DisplayInfo

    </script>


    <form name="form1">
      <center>
        <input name="update" type="button" value="revisit  page" onclick="history.go(0)"  style="background-Color:white; font-size: 8pt">
        <input name="reset"  type="button" value="reset counter" onclick="ResetCounts()"  style="background-Color:white; font-size: 8pt">
    </CENTER>
    </FORM> 


Bookmarks

Posting Permissions

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