Javascript Sweet Alert and html link inside text

后端 未结 5 1610
暖寄归人
暖寄归人 2021-01-25 10:46

i have the following SweetAlert Code..



        
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-25 11:21

    Why not try the following (I have never used sweet alert, but after reading the documentation this is what I would try)

    var link= document.createElement("a");
    link.href =  report  // or link.setAttribute("href", report)
    
    
    swal({
    title: name,
    text: "Gender: " + gender +"\n" + "Age: " + age +"\n" + "Country: " + country +"\n" + "State: " + state +"\n" + "Address: " + address +"\n" + "Report: " + report,
    confirmButtonColor: "#00B4B4",
    imageUrl: "images/avatar/user.png",
    content:link
    });
    });
    

    Or

    swal({
        title: name,
        text: "Gender: " + gender +"\n" + "Age: " + age +"\n" + "Country: " + country +"\n" + "State: " + state +"\n" + "Address: " + address +"\n" + "Report: " + report,
        confirmButtonColor: "#00B4B4",
        imageUrl: "images/avatar/user.png",
        content:{
          element:"a",
          attributes:{
            href:report
          }
         }
        });
        });
    

    hope that helps

提交回复
热议问题