Shoutbox

JS help - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: JS help (/showthread.php?tid=51751)

JS help by Supersonicdarky on 10-13-2005 at 06:26 PM

I need a js that will automaticly close a window after a certain amount of time!

i already tried fowarding to the close window js, but didn't work

help? :huh:


RE: JS help by Stigmata on 10-13-2005 at 06:31 PM

code:
<SCRIPT LANGUAGE = "JavaScript">
<!--
var secs
var timerID = null
var timerRunning = false
var delay = 1000

function InitializeTimer()
{
    // Set the length of the timer, in seconds
    secs = 10
    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock()
        alert("You have just wasted 10 seconds of your life.")
window.close
    }
    else
    {
        self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}
//-->
</SCRIPT>


then

code:
<body onLoad="InitializeTimer()">

http://www.mcfedries.com/JavaScript/timer.asp

just a edited version of some code i found :)
RE: JS help by -dt- on 10-13-2005 at 06:45 PM

ok.

stig your code wont work.

your callling
window.close .... thats a link to the function varible you need to add a () after it like
window.close();

next that code is way too long for such a simple task!
time is in millisec.

code:
window.setTimeout(function(e){window.close( ); } , 1000 );


RE: JS help by Supersonicdarky on 10-13-2005 at 07:15 PM

but in IE it asks you "The page you are viewing is trying to close the window. Do you want to close this windows now?"

anyway to bypass it?


and it doesn't work in firefox :(


RE: JS help by -dt- on 10-13-2005 at 07:17 PM

quote:
Originally posted by Supersonicdarky
but in IE it asks you "The page you are viewing is trying to close the window. Do you want to close this windows now?"

anyway to bypass it?


and it doesn't work in firefox [Image: msn_sad.gif]
[Image: xso_undecided.gif] odd i closed my tab with it.

and no unless you own that window then you cant stop it asking you.
RE: JS help by Supersonicdarky on 10-13-2005 at 07:21 PM

what do you mean by own?


RE: JS help by Plik on 10-13-2005 at 07:24 PM

quote:
Originally posted by Supersonicdarky
what do you mean by own?

If you create that window (open it from one of your pages) then you own it
RE: JS help by Supersonicdarky on 10-13-2005 at 07:27 PM

what if it's like the shoutbox, is it pwnable? :P
beacuse i'm trying to make a windows like that close

i can't explain exactly what i mean :(

examle:

i click the link with the onclick="NewWindow(this.href,'name','547','354','yes');return false" code in it, is it possible to automaticly close that?


RE: JS help by -dt- on 10-13-2005 at 07:29 PM

quote:
Originally posted by Supersonicdarky
what if it's like the shoutbox, is it pwnable? [Image: msn_tongue.gif]
beacuse i'm trying to make a windows like that close

i can't explain exactly what i mean [Image: msn_sad.gif]
yes it is.


errr in the main content you have to save the window in a varible (what window.opens returns)

then set a timeout with that varible and do varWindow.close(); 


http://developer.mozilla.org/en/docs/DOM:window.open
http://developer.mozilla.org/en/docs/DOM:window.close