小编Cod*_*ith的帖子

“Uncaught SyntaxError: Unexpected end of input” 转换为书签时

我有一个脚本和普通 JS 一样可以正常工作,但是当我使用https://mrcoles.com/bookmarklet/将其转换为书签并尝试运行它时,我得到了Uncaught SyntaxError: Unexpected end of input

我以前使用过这个网站来转换为书签,没有任何错误。如果我将未转换的代码粘贴到控制台并调用它运行良好的函数。

未转换:

function copy() {
  var number = document.getElementById('sys_readonly.rm_story.number').value,
      shortDescription = document.getElementById('rm_story.short_description').value,

      d = new Date(),
      year = d.getFullYear(),

      //The '0' and slice makes sure the numbers are at least 2 characters long. The '+1' is becuase it starts at January == 0.
      month = ('0' + (d.getMonth() + 1)).slice(-2),
      day = ('0' + d.getDate()).slice(-2),

      name = (year) + (month) + (day) + ' - ' + number + …
Run Code Online (Sandbox Code Playgroud)

javascript bookmarklet syntax-error

2
推荐指数
1
解决办法
1176
查看次数

标签 统计

bookmarklet ×1

javascript ×1

syntax-error ×1