t4t5 / sweetalert

A beautiful replacement for JavaScript's "alert"
https://sweetalert.js.org
MIT License
22.39k stars 2.84k forks source link

HTML in function.js #874

Closed Badetuch closed 5 years ago

Badetuch commented 5 years ago

Hey,

I want to have a teamspeak Viewer "inside" a Button like this: https://blur-group.eu/website/index.php/teamspeak/

How can i get this: https://hastebin.com/xebubisiwa into the Message box which pops up when i click the buttton?

Hope u understand me, sry 4 my bad English.

Greetings from Germany :)

lionralfs commented 5 years ago

Sure, you can use the content option to embed HTML:

const div = document.createElement("div");
div.setAttribute("class", "ts3index-viewer");
div.setAttribute("data-serverid", "235334");

const link = document.createElement("a");
link.href = "https://ts3index.com/?page=server&id=235334";
link.appendChild(document.createTextNode("TS3index.com"));
div.appendChild(link);

const c = document.createElement("script");
const s = document.getElementsByTagName("script")[0]; 
c.type = "text/javascript";
c.async = true;
c.src = "https://ts3index.com/viewer/script.js";
s.parentNode.insertBefore(c, s);

swal("........", {
  icon: "success",
  content: div
});
Badetuch commented 5 years ago

im sorry, i dont understand how i need to adjust my code.

t4t5 commented 5 years ago

@Badetuch We can't write all of the code for you. I think @lionralfs has given a detailed answer on how to inject custom HTML into the modal, but you'll need to do some research on your own for it to work just the way you need.

Please keep this repo for issues and bugs related to the library itself. If you want help for your personal projects, I suggest Stack Overflow. :)

Badetuch commented 5 years ago

Im so sorry now i understand it. Thanks guys