开发者

How to get an HTML link in a javascript confirm() dialog?

开发者 https://www.devze.com 2023-03-30 17:37 出处:网络
I need to add an HTML href link in the confirm dialog box, but what I am getting is the text of the href not the HTML tag).

I need to add an HTML href link in the confirm dialog box, but what I am getting is the text of the href not the HTML tag).

return con开发者_运维问答firm("Changes to your financial details may affect your GST or tax status for items already for sale via Momento Shop. Please read and confirm the Momento Shop<a target='_blank' href='/pages/terms_print'>terms and conditions.</a>")

Output of above code is:

Changes to your financial details may affect your GST or tax 
status for items already for sale via Momento Shop. Please 
read and confirm the Momento Shop terms and conditions.

But I need terms and conditions become a link (able to be clicked).


You can't do this in the built-in confirmation dialog.

Have a look at some of the available UI libraries around. jQuery UI's dialog component seems like a good fit.


In JavaScript, alert, prompt, and confirm boxes can only contain plain text. Not even images can be appended. I recommend you use a custom modal or custom alert box to display your alert boxes. With custom modals, you can pretty much display any HTML inside.


The default JavaScript confirm dialog cannot handle links (or any other rich text for that matter). You may look into using a more complex dialog library.


The confirm() from JS will not do what you are trying. You need Modal dialogue windows which can be created using some JS tool kit like jQuery

0

精彩评论

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