views:

758

answers:

2

I want to put a link in a Javascript alert.

Is this possible? (I've searching for a solution, but I keep getting things about links that fire alerts!)

+6  A: 

AFAIK you can't do that with a normal javascript alert box.

Make a custom alert box and then make a link inside it.

Here is a nice one

YUI: Dialog Alert Widget

Also a jQuery based one

jQuery Impromptu

rahul
Not sure I'd recommend YUI, but the idea is right.
Mark
YUI is good stuff. Why don't you like it?
Andrew Johnson
Come now ,Andrew, because it is obviously not jQuery, and just like in the Highlander, there can be only one.
Justin Johnson
+2  A: 

Nope. Only standard OS dialog boxes are available (alert, input, etc.), and none support embedded hyperlinks.

You can could a pop-up window that is styled to look like a dialog, but pop-up windows are likely to have various user blocks, etc. in place.

My advice is to use a an absolutely-positioned DIV with a high z-order centered on your page that looks like a dialog box and put whatever you want in it. Various UI toolkits like JQuery UI take the pain out of this.

richardtallent