Solved

How to autoclose a javascript after a certain time?

Posted on 2011-02-18
7
408 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
Independent Software Vendors: 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

735 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