开发者

can we have anchors in alerts?

I want to throw an alert message if a user enters a bad username/password and give users an option to hit "ok" which lets them try the page again or "forgot password" which lets them go to a different link to change their password.

Can I use an alert box and add an anchor to it ? I don't want to have a button floating around u开发者_C百科ntil someone enters a wrong password.


No. alert() boxes can only display plain text. If you wanted to create your own pop-up box like that you would need to implement it yourself, you couldn't use alert().


You may want to use confirm().

This function shows a message followed by a Ok and Cancel buttons:

if (confirm('You used a wrong password; Would you like to retrieve your password ?')) {
    document.location = 'retrieve the password';
}


The built-in alert function won't show hypertext, just text. You can use a fancier implementation from any one of the popular Javascript gui libraries. They will let you create an HTML pop-up instead.


alert does not display HTML. You'll have to emit markup to display the message instead. There are many libraries that can do this for you, including jQuery UI.


That's not possible. You can use the showModalDialog function instead. See the demo at this page.


No, you will have to show the user a custom message. You may want to use absolutely positioned DIV element, a modal dialog window or an iframe for that purpose.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜