Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.9k views
in Technique[技术] by (71.8m points)

typecho网页报错:Uncaught SyntaxError: Invalid or unexpected token

下了个typecho模板,发现Uncaught SyntaxError: Invalid or unexpected token这个问题,定位了下,好像是下面这段代码导致的。

麻烦大佬帮忙看一下,正确的写法该怎么写(貌似是最后两行的问题),谢谢~

<script type="text/javascript">
    (function () {
            var event = document.addEventListener ? {
                    add: 'addEventListener',
                    triggers: ['scroll', 'mousemove', 'keyup', 'touchstart'],
                    load: 'DOMContentLoaded'
                } : {
                    add: 'attachEvent',
                    triggers: ['onfocus', 'onmousemove', 'onkeyup', 'ontouchstart'],
                    load: 'onload'
                },
                added = false;
            document[event.add](event.load, function () {
                        var r = document.getElementById('respond-post-14'),
                            input = document.createElement('input');
                        input.type = 'hidden';
                        input.name = '_';
                        input.value = (function () {
                                    var _lxrVuZJ = '7c7' +
                                    /* 'q'+'8'+'6c'+/* '9Be'+'e'+'d1b'+''+'b'+'73'+'4ba'+'d'+'2c'+'f'+'b6'+'258'+'c'+'4'+'64', _O6K7Z = []; for (var i = 0; i < _O6K7Z.length; i ++) { _lxrVuZJ = _lxrVuZJ.substring(0, _O6K7Z[i][0]) + _lxrVuZJ.substring(_O6K7Z[i][1]); } return _lxrVuZJ;})(); if (null != r) { var forms = r.getElementsByTagName('form'); if (forms.length > 0) { function append() { if (!added) { forms[0].appendChild(input); added = true; } } for (var i = 0; i < event.triggers.length; i ++) { var trigger = event.triggers[i]; document[event.add](trigger, append); window[event.add](trigger, append); } } } });})();
</script>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
-/* 'q'+'8'+'6c'+/*
+/* 'q'+'8'+'6c'+*/

一个星号位置不对引发的血案。
得亏 segmentfault 可以高亮 JS 代码,不然你这个问题贴到贾跃亭回国都不会有答案。
话说你是用类似记事本这种不带语法高亮的东西写的代码吗?如果是的话换个带高亮的编辑器,比如 VScode。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...