[英]How to put a <script> inside a <script>?
JS noob here. JS 菜鸟在这里。 I'm not sure if this if I'm doing this correctly but I'm trying to run a script "within" another script.我不确定这是否正确,但我正在尝试在另一个脚本“内”运行一个脚本。
<script type="text/discourse-plugin" version="0.8">
api.decorateWidget('post:after', helper => {
let post = helper.getModel();
if (post.get('post_number') % 3 === 0) { // after every 3 posts
return helper.rawHtml(`
<div class="lead_static_wrapper"><p>Label</p>
<div class="proper-ad-unit">
<div id="pr-ad-nr_main_1">
propertag.cmd.push(function() { proper_display('nr_main_1'); });
</div>
</div>
</div>
`);
}
});
</script>
I need this part to run but it just shows as text when live, and doesn't seem to be running.我需要这部分才能运行,但它在直播时只显示为文本,似乎没有运行。
propertag.cmd.push(function() { proper_display('nr_main_1'); });
This doesn't seem to be the working:这似乎不是工作:
<script type="text/discourse-plugin" version="0.8">
api.decorateWidget('post:after', helper => {
let post = helper.getModel();
if (post.get('post_number') % 3 === 0) { // after every 3 posts
return helper.rawHtml(`
<div class="lead_static_wrapper"><p>Label</p>
<div class="proper-ad-unit">
<div id="pr-ad-nr_main_1">
<script>propertag.cmd.push(function() { proper_display('nr_main_1'); });</script>
</div>
</div>
</div>
`);
}
});
</script>
Is there a way to edit the JS structure so this works?有没有办法编辑 JS 结构,这样就可以了? I'm trying to make this work for Discourse forums.我正在努力使这项工作适用于 Discourse 论坛。 Any help is appreciated!任何帮助表示赞赏! Thanks!谢谢!
使用反斜杠来转义结束斜杠。
<script>propertag.cmd.push(function() { proper_display('nr_main_1'); });<\/script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.