简体   繁体   English

HTML onclick事件未加载JavaScript函数

[英]HTML onclick event not loading JavaScript function

So I'm having issues with my onclick function that I wasn't having before. 因此,我的onclick函数遇到了以前没有的问题。 When I originally implemented it on the page, it was working perfectly. 当我最初在页面上实现它时,它运行良好。 Then, once I changed the location of the JS file to a subfolder in the directory, (and changed the location in my HTML) the onclick link I made stopped calling the JS function. 然后,一旦我将JS文件的位置更改为目录中的子文件夹(并更改了HTML中的位置),我制作的onclick链接就停止了调用JS函数。

function namePrompt() {
    var x=prompt("Enter your first and last name:");
    if (x) {
      window.location.href = "http://database.gchandel.com/app_edit.php?name="+x;
    }
}

Above is the JS code I'm using, and below is the line that calls the function. 上面是我正在使用的JS代码,下面是调用该函数的行。

<a onclick="namePrompt()">click this link to view your entry.</a>

I've tried everything from moving the file back to its original location, to refreshing the page many times, to changing things like function name and file name and none of this has given me any luck. 我已经尝试了所有方法,从将文件移回其原始位置,多次刷新页面,更改函数名和文件名之类的方法,这些都没有给我带来任何运气。

Also, here's the link to the site I'm working on: database.gchandel.com 另外,这是我正在工作的网站的链接: database.gchandel.com

The problem is in your prompt syntax, check it here 问题出在您的提示语法中,请在此处检查
Syntax of prompt is 提示的语法是

prompt("", "");


While working one is here 当一个人在这里

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

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