Solved

How to autoclose a javascript after a certain time?

Posted on 2011-02-18
7
409 Views
Last Modified: 2012-06-21
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!
0
Comment
Question by:Wikkiboy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 7

Expert Comment

by:dxdinh
ID: 34930620
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
 
LVL 7

Accepted Solution

by:
dxdinh earned 250 total points
ID: 34930633
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
 
LVL 16

Expert Comment

by:sjklein42
ID: 34930635
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Wikkiboy
ID: 34930648
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
 
LVL 7

Expert Comment

by:dxdinh
ID: 34930725
in that case - the only option is to inject your message to the streaming video ....
0
 

Author Comment

by:Wikkiboy
ID: 34931645
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
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 34932657
But there are ads in youtube videos.

Since 2007 it seems

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

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question