• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

How to make a Popup using HTML/Javascript?

Status
Not open for further replies.
I'll cut it short. Pretty much I'm not that good of a coder yet, especially with this kind of stuff, but I really need help solving it.

So, the case is about popup (I know bunch of people hate em, but I need this one done). What I currently need are :
1. Dimming the page while the popup is active
2. Locking the popup to the middle of the page
3. Run an auto close after X second
 
Level 28
Joined
Mar 25, 2008
Messages
2,955
http://www.w3schools.com/js/js_popup.asp

This is what you're looking for I suppose.

If you want an alert to appear and disappear after a specified interval has passed, then you're doomed.
When an alert has triggered, the browser stops processing the js code until the user clicks "Ok".
This happens again when a confirm or prompt is shown.

OR:
http://stackoverflow.com/questions/18650494/disappear-the-alert-box-with-time-based
^pure JS Bin dialog custom alert

You can use jqueryUI (-> Dialog widget) too.
Further stuff: https://blog.udemy.com/jquery-popup-window/

I'd use jquery for that - it's highly customizable and fairly easy to get into...

http://www.w3schools.com/jsref/met_win_settimeout.asp
may also benefit your thing
 

sentrywiz

S

sentrywiz

I'll cut it short. Pretty much I'm not that good of a coder yet, especially with this kind of stuff, but I really need help solving it.

So, the case is about popup (I know bunch of people hate em, but I need this one done). What I currently need are :
1. Dimming the page while the popup is active
2. Locking the popup to the middle of the page
3. Run an auto close after X second

You know, stackoverflow is your place for programming. As much as I love hive, 99% of the time i just ask on stackoverflow... lightning fast answers, on the point. Also googling tutorials helps too.


This site is hated among devs. You can google the reasons. My advice:
- its okay for short syntax check or their online try-it-editor
- don't follow their tutorials blindly
- don't use it for references. people hate it for reasons older than you and me (often called w3fools)
 
Level 19
Joined
Jul 2, 2011
Messages
2,162
its pretty easy to do.

give the background a name. I should have one already but it's better if you give it one. my backgrounds are always called, 'gameback'

then write.

gameback.setenabled(false);
JOptionpane.showMessageDialogue(null,"pop up message.what ever you want it to be");
timer ();
gameback.setEnabled(true);

then using a thread timer, you will have to Google how to use threads.

write

public timer(){
Thread.yield();
Thread.sleep(8000);
}
this will make the pop up window last 80 seconds and if you click something on the pop up it will then resume the gameback

I hope this helps you Daffa! the thread will provably be the hardest part
 
Status
Not open for further replies.
Top