Javascript 在 slack 帖子中嵌入 html
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36259417/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Embed html in slack posts
提问by user1452936
I have a html message like this:
我有这样的 html 消息:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<script type="text/javascript">
(function(){
document.writeln("<iframe src=\"http://www.example.com" width=\"100%\" height=\"100%\" frameborder=\"0\"></iframe>");
})();
</script>
</head>
<body>
<h1>hello world!</h1>
</body>
</html>
How can i post this as a message in slack ? Does slack accept HTML ?
我如何在 slack 中将此作为消息发布?slack 接受 HTML 吗?
var message = {
mrkdwn: true,
text: "", //This does not accept my above HTML code
attachments : []
};
slacker.notify(message, function(err, result) {
callback(err, result);
});
回答by Eray
Slack doesn′t allow HTML elements. But you can format your text with its Markdown flavor, which allows (links, bold, italic etc)
Slack 不允许 HTML 元素。但是您可以使用 Markdown 风格来格式化您的文本,这允许(链接、粗体、斜体等)
It won't allow javascripts or iframes because of security.
出于安全考虑,它不允许使用 javascript 或 iframe。
Details : https://api.slack.com/docs/formatting