Solved

How to autoclose a javascript after a certain time?

Posted on 2011-02-18
7
404 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
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
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…

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now