473,327 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

[JS] setTimeout nie działa...

Mam funkcję którą wywołuję w
<form ... onSubmit="submit_f()">

a funkcja wygląda tak:

<script>
function submit_f(){
window.opener.location.reload();
setTimeout("window.close();",3000);
}
</script>

Całość odbywa się w popupie i ma polegać na tym, że po
przetworzeniu formularza ma to zostać przeładowana strona z której
otwarłem popupa i po 3 sekundach zamknięty popup (jeśli daję bez
opóźnienia to czasami nie przetworzy formularza). Niestety nie
działa ten setTimeout i nie zamyka strony. Jak dam alert('ble'); po
setTimeout to wyswietl alerta i zamknie popup. Co to może być?

Sep 26 '06 #1
1 4010

wo****@gmail.com napisał(a):
Mam funkcję którą wywołuję w
<form ... onSubmit="submit_f()">

a funkcja wygląda tak:

<script>
function submit_f(){
window.opener.location.reload();
setTimeout("window.close();",3000);
}
</script>

Całość odbywa się w popupie i ma polegać na tym, że po
przetworzeniu formularza ma to zostać przeładowana strona z której
otwarłem popupa i po 3 sekundach zamknięty popup (jeśli daję bez
opóźnienia to czasami nie przetworzy formularza). Niestety nie
działa ten setTimeout i nie zamyka strony. Jak dam alert('ble'); po
setTimeout to wyswietl alerta i zamknie popup. Co to może być?
Jednym z rozwiązań (ale bardzo kiepskim bo będzie ono zrzerało czas
proca), jest takie:

plik main.html
--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title></title>
</head>
<body>
<script type="text/javascript">
var globalRef;

document.write(Math.random(500));

</script>
<br>
<a href="#" onclick="globalRef = window.open('popup.html');">Otwórz
popup</a>
</body>
</html>

plik popup.html
----------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="generator" content="PSPad editor, www.pspad.com">

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

function submit_f() {
var fromT = (new Date()).getTime();
for (var i = 0; i < 3000; i = (new Date()).getTime() - fromT)
{
// tutaj niestety jest zabierany czas procesora...
}
window.location.reload();
window.close();
}
</script>
<form name="myForm" onsubmit="submit_f()">
<input type="submit" value="Przeładuj stronę...">
</form>
</body>
</html>

Pozdrawiam i mam nadzieję że to pomogło.

Łukasz Matuszewski

Oct 2 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Knocked Wood | last post by:
Hi, I looked around and can't find anything on this at all and can not get it to work for IE. I'm trying to loop multiple sounds on a game, with three unique variables, when a link is clicked....
3
by: Grzegorz | last post by:
Hi All, I encountered recently the following strange behavior of JS: I need to create a simple page that contains one button. After clicking it there should be generated two short sounds with a...
13
by: Martin Mrazek | last post by:
Hi, I check data validity in html form by JS. Something like for (i=0; i<document.form.elements.length; i++) { chechkValidity(i); } Unfortunately, the form has about two thousands elements...
17
by: CES | last post by:
All, I was wondering if their is a way of loading an external script fill from within a script?? <script language="javascript" type="text/javascript"> function test(var){ <script...
5
by: gimme_this_gimme_that | last post by:
I'd like to create my own version of google suggest GS. If you haven't seen GS check it out at : http://www.google.com/webhp?complete=1&hl=en I've reviewed several AJAX write-ups on the...
10
by: Robert Skidmore | last post by:
Take a look at this new JS function I made. It is really simple but very powerful. You can animate any stylesheet numeric value (top left width height have been tested), and works for both % and px...
4
by: Yotam | last post by:
Hi, I need some help with JS. I will be grateful, if you can help me out. I have two date fields (check in, check out) and "number of days" field. I want the script to calculate automatically...
4
by: STIAdmin | last post by:
Happy Holidays to all of you! This is my first time posting. I'm working on a web project and trying to get this done before Christmas. The limitation is that I'm using an out of the box program...
19
by: joebloe | last post by:
Which browsers, if any, other than FF2/3, support Javascript 1.7? And in those, how do you turn it on? As in, for FF2 you must say: <script type="application/javascript;version=1.7"> or the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shćllîpôpď 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.