最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

css - Javascript Compiler Error in Google Tag Manager: this language feature is only supported for ECMASCRIPT6 mode or better -

programmeradmin7浏览0评论

I'm getting the following error message in Google Tag Manager:

Error at line 6, character 282: this language feature is only supported for ECMASCRIPT6 mode or better: block-scoped function declaration. Use --language_in=ECMASCRIPT6 or ECMASCRIPT6_STRICT or higher to enable ES6 features.

when adding this Inter snippet tag

<script>
    window.interSettings = { app_id: {{inter_chat_widget_id}} };
</script>

<script>
    (function () { var w = window; var ic = w.Inter; if (typeof ic === "function") { ic('reattach_activator'); ic('update', interSettings); } else { var d = document; var i = function () { i.c(arguments) }; i.q = []; i.c = function (args) { i.q.push(args) }; w.Inter = i; function l() { var s = d.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = '/{{inter_chat_widget_id}}'; var x = d.getElementsByTagName('script')[0]; x.parentNode.insertBefore(s, x); } if (w.attachEvent) { w.attachEvent('onload', l); } else { w.addEventListener('load', l, false); } } })()
</script>

For this section of the code i = function () {

I'm getting the following error message in Google Tag Manager:

Error at line 6, character 282: this language feature is only supported for ECMASCRIPT6 mode or better: block-scoped function declaration. Use --language_in=ECMASCRIPT6 or ECMASCRIPT6_STRICT or higher to enable ES6 features.

when adding this Inter snippet tag

<script>
    window.interSettings = { app_id: {{inter_chat_widget_id}} };
</script>

<script>
    (function () { var w = window; var ic = w.Inter; if (typeof ic === "function") { ic('reattach_activator'); ic('update', interSettings); } else { var d = document; var i = function () { i.c(arguments) }; i.q = []; i.c = function (args) { i.q.push(args) }; w.Inter = i; function l() { var s = d.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = 'https://widget.inter.io/widget/{{inter_chat_widget_id}}'; var x = d.getElementsByTagName('script')[0]; x.parentNode.insertBefore(s, x); } if (w.attachEvent) { w.attachEvent('onload', l); } else { w.addEventListener('load', l, false); } } })()
</script>

For this section of the code i = function () {

Share Improve this question edited Feb 8, 2019 at 2:44 Cœur 38.8k25 gold badges205 silver badges277 bronze badges asked Feb 22, 2018 at 8:37 Charlie HowesCharlie Howes 431 gold badge2 silver badges8 bronze badges 5
  • 1 Please don't include images of text, you need to include the text directly in the question. Google Tag Manager allows you to inject code (tags) into the users browser session: someone has written a tag that uses a version of JS too new for the target browser. – Richard Commented Feb 22, 2018 at 8:39
  • Please include the code here. – Harun Diluka Heshan Commented Feb 22, 2018 at 8:41
  • Hey guys, Okay thanks for the information - I thought it would be easier to isolate the character with an image. – Charlie Howes Commented Feb 22, 2018 at 9:09
  • Possible duplicate of Why am I getting a JavaScript piler error when trying to publish changes to my inter tag in Google Tag Manager? – nyuen Commented Feb 23, 2018 at 1:08
  • This is possibly a duplicate of stackoverflow./questions/48440623/… – nyuen Commented Feb 23, 2018 at 1:09
Add a ment  | 

2 Answers 2

Reset to default 4

This worked for me in Google Tag Manager:

<script>
    window.interSettings = { app_id: {{inter_chat_widget_id}} };
</script>

<script>
    (function () { var w = window; var ic = w.Inter; if (typeof ic === "function") { ic('reattach_activator'); ic('update', interSettings); } else { var d = document; var i = function () { i.c(arguments) }; i.q = []; i.c = function (args) { i.q.push(args) }; w.Inter = i; var l = function () { var s = d.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = 'https://widget.inter.io/widget/{{inter_chat_widget_id}}'; var x = d.getElementsByTagName('script')[0]; x.parentNode.insertBefore(s, x); }; if (w.attachEvent) { w.attachEvent('onload', l); } else { w.addEventListener('load', l, false); } } })()
</script>

What has changed here is that

function l() { ... }

has been changed to

var l = function () { ... };

You need to declare a variable using the var keyword.

You currently pare something to a non-existing variable, you also use strict equality, which is impossible because there is no type to qualify the strict equality to, vinoaj workaround is what you want.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论