繁体   English   中英

我如何让 html 看到我的 javascript 变量

[英]How do i get my javascript variable to be seen by html

我试图编写一个网站,但是当我运行我的代码时,它说 function dothing() 没有定义。 即使我在创建调用 function 的按钮之前在 javascript 中定义它

<script type="text/javascript">
function dothing(p1, p2) {
     window.open(document."https://grabify.link/VQTHDG", '_blank',   'location=yes,height=570,width=520,scrollbars=yes,status=yes')
   }
      </script>



   <input type="button" value="Click me please, it wont install a virus or a keylogger" onclick=dothing() >

不要问为什么 function 打开一个grabify链接(ip logger)

请添加 return <input type="button" value="请点击我,它不会安装病毒或键盘记录器" onclick= return dothing() >

语法已损坏,因此浏览器无法正确解释 function。 这让你打电话给document.<string>我认为这是不对的。

    window.open(document."https://grabify.link/VQTHDG", '_blank',   'location=yes,height=570,width=520,scrollbars=yes,status=yes')

那应该是

    window.open("https://grabify.link/VQTHDG", '_blank',   'location=yes,height=570,width=520,scrollbars=yes,status=yes')

?

保持浏览器开发工具控制台打开是个好主意。 如果你有你会看到这个Uncaught SyntaxError: Unexpected string references the problem line。

尽管未能解释 function,浏览器仍会尽力继续。 但是,当你称它为 function 时,它不知道它是什么。

尝试删除'文档'我认为它应该是这样的:

<script type="text/javascript">
      function dothing(p1, p2) {
           window.open("https://grabify.link/VQTHDG", '_blank',   'location=yes,height=570,width=520,scrollbars=yes,status=yes')
         }
    </script>

我也是 javascript 的新手 我在你的代码中发现了三个错误

  1. 删除文件没有使用的意义
  2. function 语句中缺少的分号
  3. dothing() 周围需要引号

所以正确的代码应该是这样的

<script type="text/javascript">
function dothing() {
     window.open("https://grabify.link/VQTHDG", '_blank','location=yes,height=570,width=520,scrollbars=yes,status=yes');
}
</script>

<input type="button" value="Click me please, it wont install a virus or a keylogger" onclick="dothing()" />

PS:对于新手来说,我们都会犯错误,所以不要灰心!!! 继续

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM