Javascript 从typescript文件加载html脚本

Javascript 从typescript文件加载html脚本,javascript,html,typescript,chatbot,Javascript,Html,Typescript,Chatbot,我现在正在一个聊天机器人中集成nps小部件。我无法向您显示所有代码,但我在chat.ts文件中导入了html文件。我想在聊天机器人按下按钮后调用整个html文件。我试了很多,但似乎没有任何帮助 这是chat.ts代码(其中的一小部分) 这是npshtml文件 <html> <body id="try"> <p> AskNicely Web Survey Popup Example for traditional websites.<br>

我现在正在一个聊天机器人中集成nps小部件。我无法向您显示所有代码,但我在chat.ts文件中导入了html文件。我想在聊天机器人按下按钮后调用整个html文件。我试了很多,但似乎没有任何帮助

这是chat.ts代码(其中的一小部分)

这是npshtml文件

<html>
<body id="try">
<p>
    AskNicely Web Survey Popup Example for traditional websites.<br>
    Running in 'force' mode.<br>
    Responses will be recorded.
</p>
<script type="text/javascript" src="https://static.asknice.ly/dist/standalone/asknicely-in-app-conversation.js"></script>
<link href="https://static.asknice.ly/dist/standalone/asknicely-in-app-conversation.css" rel="stylesheet" type="text/css" charset="utf-8">
<script type="text/javascript">
    document.addEventListener('DOMContentLoaded', function () {

        askNicelyConversation({
            config: {
         --- cannot show this part  --- 
            },
            customData: {
                a_custom_property: 'business', // Optional - Send extra data about this customer for reporting and leaderboards
                another_custom_property: 'New York' // Optional - Send extra data about this customer for reporting and leaderboards
            }
        });
    });
</script>
</body>
</html>


AskNicely传统网站的网络调查弹出窗口示例。
在“强制”模式下运行。
将记录答复。

document.addEventListener('DOMContentLoaded',函数(){ askNicelyConversation({ 配置:{ ---无法显示此部分-- }, 客户数据:{ a_custom_属性:“business”,//可选-发送有关此客户的额外数据以用于报告和排行榜 另一个_custom_属性:“New York”//可选-发送有关此客户的额外数据以用于报告和排行榜 } }); });
我还用css在另一个html文件中呈现了这个按钮,但一切正常

我目前在windows.location.assign上有它,因此它会打开一个新页面。如果可以在不打开新页面的情况下触发脚本,这将是理想的


使用jquery.load不起作用,也不会给我带来某种错误

“似乎没有什么帮助”听起来很模糊。如果你执行这个脚本会发生什么?我多次改变了showAskNicely的工作方式。我从来没有犯过错误。按照当前的设置方式,它只能将页面拍摄到无法获取/npshtml.html的位置。我还尝试用Jquery.load调用html部分
<html>
<body id="try">
<p>
    AskNicely Web Survey Popup Example for traditional websites.<br>
    Running in 'force' mode.<br>
    Responses will be recorded.
</p>
<script type="text/javascript" src="https://static.asknice.ly/dist/standalone/asknicely-in-app-conversation.js"></script>
<link href="https://static.asknice.ly/dist/standalone/asknicely-in-app-conversation.css" rel="stylesheet" type="text/css" charset="utf-8">
<script type="text/javascript">
    document.addEventListener('DOMContentLoaded', function () {

        askNicelyConversation({
            config: {
         --- cannot show this part  --- 
            },
            customData: {
                a_custom_property: 'business', // Optional - Send extra data about this customer for reporting and leaderboards
                another_custom_property: 'New York' // Optional - Send extra data about this customer for reporting and leaderboards
            }
        });
    });
</script>
</body>
</html>