Javascript open new popup window with 5 second time delay

hi everyone.

i need to delay a page from opening a new window for a minimum of 5 seconds to allow some php processing (inserting a new record into a table) to occur first. the open window code works fine without the time delay, but as soon as i attempt to put a delay in, nothing happens eg, the page no longer opens a new window called newrecord.php. i’d appreciate some help. thx.

a submit button calls the function like so:
<input type=“submit” name=“AddRecord” id=“AddRecord” value=“Add New Record” onClick=“confirmCreateNewRecord()” />

	function confirmCreateNewRecord()
		var isConfirmed=confirm('Are you sure you wish to create a new  record now? This action cannot be undone or cancelled.')
	function redirectUser()
	{"newrecord.php?ID=<?php echo $ID ?>","_blank","toolbar=no, location=yes, status=no, menubar=no, scrollbars=yes, resizable=yes, width=800, height=550");

May be a popup blocker problem.

When the function fires the “redirectUser()” without the delay it work because it’s in the same “event scope” that it happens, so, the browsers “thinks” “ok, this popup is what the user want to see”.

Instead, when you put it into a “setTimeout()” the call is being generated from the JavaScript engine, so, the browser “thinks” “what is that? who is telling me to open a new window? may be an ad, i will discard this call” or similar :rofl:

So, check your popup blocker rules to see if this is what is happening.

See you :cool:

Thanks for the reply.

I really got frustrated with why the time delay didn’t work, so instead, i just called a php routine with the ‘sleep’ method then used a header redirect. that seemed to give me what i needed. plus it avoided javascript!