SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Oct 2001
    Location
    Lisbon
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    View Time session limited

    Hello ppl!

    I would like to know if somebody can help me out. I need a script to put in a webpage, with a time limitation. I have a page that i just want to the "user" have 5 minutes to be on that page, and he could also see that time displaying... When it finish (the 5 minutes) he goes directly to another page( a page that says the user has to login again.)

    If someone knows a good script i would like to know please

    Thanks in advanced!!!
    Alex Vasconcelos (Portugal)

  2. #2
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you good enough with Javascript to try writing it yourself.

    If you make a start i'm sure we'd all be happy to help - and you'd learn more about Javascript in the process.

    It's far better for you than using someone else's script!

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  3. #3
    SitePoint Member
    Join Date
    Oct 2001
    Location
    Lisbon
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <script language="javascript">

    var running = false
    var endTime = null
    var timerID = null

    function timer(){

    running=true
    now = new Date()
    now = now.getTime()
    endTime = now+(1000*300*1)
    endIt()
    }

    function endIt(){
    var now = new Date()
    now = now.getTime()
    if(endTime - now <=0){

    //this is where you put the href to the login page
    alert("You have to login again")
    location.href="Login.html"

    }else{
    var delta = new Date(endTime - now)
    var min = delta.getMinutes()
    var sec = delta.getSeconds()
    var Time = min
    Time+=((sec <10)?":0" : ":")+sec
    document.forms[0].timeuser.value=Time
    if(running){
    timerID = setTimeout("endIt()",1000)
    }
    }
    }
    window.onload=timer
    </script>

    <form>
    <input type="text" name="timeuser">
    </form>



    can i make this a .js like time.js and put in all my 50 webpages... and in another frame make or put the form? i have a frame that have only the menu bar, and i want to put the time there... the other frame run the selected links from the menu, and there i can put the time.js... Can i do it? If you can please help me ...
    Alex Vasconcelos (Portugal)

  4. #4
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well -

    1) you don't need to have a form to have an input ;-)

    2) Sure you can put it in a .js file - you could even have it so that the .js file makes the input boxes itself - if you wanted.

    3) Maybe you could have a SSI (server side include) to put both the .js file and the input in every page - so that you can make changes easily.

    Why not have the .js file and the input box ( not that it has to be an input box - it could just be a span ) - into the same frame - what difference does it make - you just reset the timer in the menu frame everytime it changes the location of the content frame.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---


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
  •