未捕获的参考错误:未定义功能

时间:2022-11-05 14:48:49

I'm working on an app for webOS that will take a megaupload link(assuming its a video), parse it into a direct link and stream it to a ffplay port for webos called TouchPlay. I'm working on a basic prototype that will just take the end code on a megaupload link and return a direct link. Now that I have laid out the basic parts of my application, on to my question. I want to take data in a form in an html page and feed it into a function in an external js script. Here's the html portion

我正在开发一个webOS应用程序,它将采用一个megaupload链接(假设它是一个视频),将其解析为直接链接并将其流式传输到一个名为TouchPlay的web的ffplay端口。我正在研究一个基本的原型,它只需要在megaupload链接上获取结束代码并返回直接链接。现在我已经列出了我的应用程序的基本部分,我的问题。我想在html页面中获取表单中的数据并将其提供给外部js脚本中的函数。这是html部分

<html>
    <head>
        <script LANGUAGE="JavaScript" src="source/main.js"></script> 
    </head>
    <body>
        <form NAME="myform" ACTION="" METHOD="GET">
            Enter the MegaUpload Code, ex. megaupload.com/?d=glgrn8f1 -> glgrn8f1: <BR>
            <INPUT TYPE="text" NAME="inputbox" VALUE="">
            <INPUT TYPE="button" NAME="button" Value="Click" onClick="javascript:codeIn(this.form);">
        </form>
    </body>
</html>

And in my main.js file is in a subdirectory called source and it contains function codeIn(code){ plus the rest of the functions.

在我的main.js文件中有一个名为source的子目录,它包含函数codeIn(code){以及其余的函数。

Yet when I enter some test data in my web page and hit submit, I get an error in the chrome dev console saying Uncaught Reference Error: codeIn is not defined

然而,当我在我的网页中输入一些测试数据并点击提交时,我在chrome dev控制台中收到一条错误,指出未捕获的参考错误:未定义codeIn

I have a very limited experience with html and javascript, but I cant seem to figure this out, I imagine its something really simple that I'm missing.

我对html和javascript的经验非常有限,但我似乎无法弄清楚这一点,我想它的东西很简单,我很想念。

EDIT: Here's main.js, and yes, I have checked for typos. Just ask if you need to see the contents of any of these functions, but I didn't think they were neccesary.

编辑:这是main.js,是的,我检查过拼写错误。只要问你是否需要查看任何这些功能的内容,但我认为它们不是必需的。

function codeIn(code){
    ...
}

function getInfo(url){
    ...
}

function waiting(timer){
...

}

Ive looked through all these suggestions and it all seems to point to a syntax error, yet when I try to put all the js functions into the head of the html, it works. So thats what I'm doing. I don't change a single thing when I reference it from source/main.js, but whatever.

我看了所有这些建议,这似乎都指向一个语法错误,但当我尝试将所有js函数放入html的头部时,它的工作原理。这就是我正在做的事情。当我从source / main.js引用它时,我不会改变任何东西,但无论如何。

2 个解决方案

#1


2  

From the look of it, I think you then need to double check the location of main.js. Verify whether your HTML file is in a location from where main.js can be accessed as source/main.js, rather than something like ../source/main.js (in case your HTML file is in a folder parallel/sibling to the source folder)

从它的外观来看,我认为你需要仔细检查main.js的位置。验证您的HTML文件是否位于main.js可以作为source / main.js访问的位置,而不是像../source/main.js那样(如果您的HTML文件位于并行/兄弟的文件夹中)源文件夹)

#2


1  

The RefereceError in general related to the scope of function that is present and the function call that is being made. It might the source path of the js, html/xhtml/jsp or function scope with in the js file. Hope this helps. Thanks.

RefereceError通常与存在的函数范围和正在进行的函数调用有关。它可能是js文件中js,html / xhtml / jsp或函数作用域的源路径。希望这可以帮助。谢谢。

#1


2  

From the look of it, I think you then need to double check the location of main.js. Verify whether your HTML file is in a location from where main.js can be accessed as source/main.js, rather than something like ../source/main.js (in case your HTML file is in a folder parallel/sibling to the source folder)

从它的外观来看,我认为你需要仔细检查main.js的位置。验证您的HTML文件是否位于main.js可以作为source / main.js访问的位置,而不是像../source/main.js那样(如果您的HTML文件位于并行/兄弟的文件夹中)源文件夹)

#2


1  

The RefereceError in general related to the scope of function that is present and the function call that is being made. It might the source path of the js, html/xhtml/jsp or function scope with in the js file. Hope this helps. Thanks.

RefereceError通常与存在的函数范围和正在进行的函数调用有关。它可能是js文件中js,html / xhtml / jsp或函数作用域的源路径。希望这可以帮助。谢谢。