How to autoclose a javascript after a certain time?

Hi

I am working on a webpage meant to display an alert after certain seconds. I have done this successfully but when I try to get it automatically disappear, every method fails.

B/W I must tell you that I cannot use <div> tags or new window popup in this particular scenario. I know those methods but dont need them in here.

Thanks in advance!
WikkiboyAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
dxdinhConnect With a Mentor Commented:
side note calling alert or confirm or prompt functions will freeze all script processing and focus - until the user response - those functions will freeze entire browser until user click
0
 
dxdinhCommented:
it's impossible for you to do that - once you activate the alert (' your data here'); there is nothing running even your timer - so your best bet is to use modal dialog or "div" which consider a better practice ...

more on this with jQuery plug which provide a nice looking modal dialog box

http://jquery.malsup.com/block/

0
 
sjklein42Commented:
You will want to embellish, but this is a simple example of popping up a window for three seconds and then auto-closing it.
In this example the window is blank but you can set the first argument of window.open to a real URL.

<script>
popup = window.open("","mypopup","location=1,status=1,scrollbars=1,width=100,height=100");
setTimeout('popup.close()', 3000);
</script>
My Main Window

Open in new window

0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
WikkiboyAuthor Commented:
Your Comment is certainly useful, but my problem is that I need to display a certain message while playing a video on iphone. Its iphone default behaviour that it runs video in its own player rather than browser. So modal dialogue only displays message on browser rather than on the video player. However alert displays above all solving my problem.

Please advise some other solution.
0
 
dxdinhCommented:
in that case - the only option is to inject your message to the streaming video ....
0
 
WikkiboyAuthor Commented:
But in case of iphone thats not possible, if that was possible we could have seen google ads while running youtube videos in iphone video player.

Please advise!
0
 
Michel PlungjanIT ExpertCommented:
But there are ads in youtube videos.

Since 2007 it seems

http://www.webtvwire.com/youtube-adverts-already-here/
0
All Courses

From novice to tech pro — start learning today.