PDA

View Full Version : Alert!!!



IanMarlowe
08-02-2005, 07:14 AM
<script type="text/javascript">
alert("What do you want!?");
</script>

is the text for an alert box to pop-up when a user loads a page.
My question:
Is there a way to animate the pop-up? Colors? Pictures? Anything? I have tries HTML, and come up with only stupid things. Any ideas???

Twey
08-02-2005, 08:33 AM
You can't do anything to an alert - it pops up, the user clicks OK, it goes away again. If you want to add eye-candy, you'll have to use a seperate window, or perhaps a pseudo-popup in a div.

IanMarlowe
08-02-2005, 08:41 AM
pseudo-popup in a div
What is that? How do I do that?

Twey
08-02-2005, 08:57 AM
You have a floating div, then you use images to give it a titlebar and buttons so it looks a bit like a popup. Tends to only work well on Windows users, but others will get the idea.

IanMarlowe
08-02-2005, 10:56 AM
hm.......sounds interesting. so basically
onload
open popup.html target="_blank"
?

Twey
08-02-2005, 11:49 AM
No, that would be an actual popup.
http://www.mattkruse.com/javascript/popupwindow/source.html includes code to do this.

IanMarlowe
08-02-2005, 12:09 PM
whoa it's long!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! I don't need anything that "complex" or that "long" I'll just go with
<body>


<script type="text/javascript">
onload()
document.open "alert.html" target="_blank"
</script>

Twey
08-02-2005, 01:15 PM
(shrug)
I suggest you use:

<script type="text/javascript">
window.open("alert.html");
</script>

IanMarlowe
08-02-2005, 01:16 PM
will it auto-open on load? :confused:

Twey
08-02-2005, 01:33 PM
Yep. The code is executed exactly as it is, when the browser sees it. You seem to have this thing about document.open. It does not redirect the browser. Also, you must include parentheses around the arguments to a function. This isn't Visual Basic.

IanMarlowe
08-02-2005, 01:40 PM
ah.......too bad ;)