在简短的帖子中嵌入html

时间:2016-03-28 09:24:52

标签: javascript html slack

我有一条这样的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>

我如何将此作为消息发布?松弛是否接受HTML?

var message = {
        mrkdwn: true,
        text: "",      //This does not accept my above HTML code
        attachments : []
    };

    slacker.notify(message, function(err, result) {
        callback(err, result);
    });

1 个答案:

答案 0 :(得分:7)

Slack不允许使用HTML元素。但您可以使用Markdown风格格式化文本,这允许(链接,粗体,斜体等)

由于安全性,它不允许使用javascripts或iframe。

详细信息:https://api.slack.com/docs/formatting