admin管理员组文章数量:1026989
So I'm pretty new to javascript...right now I'm just writing that dynamic logout button that will go log the user out before reloading the page. I wrote the function (this is actually my entire script.js file):
var scriptLoaded = true;
function confirm_logout()
{
var logout = GetURL('logout_confirm.php');
if(logout == 'true')
{
location.reload(true);
return true;
}
else
{
return false;
}
}
And then I'm loading it up with this:
<script type="text/javascript" src="script/script.js">
var scriptLoaded = false;
</script>
So what I'd like is just put it inside an anchor tag, but for the sake of testing (it wasn't working, and I just wanted to slim it down) I did this:
<script type="text/javascript">
var LoggedOut = false;
if(scriptLoaded == true)
{
LoggedOut = confirm_Logout();
}
document.write(LoggedOut);
</script>
Then I run it in chrome and in the debugging console I get the error: Uncaught ReferenceError: confirm_Logout is not defined (anonymous function).
Help me stack overflow, you're my only hope.
So I'm pretty new to javascript...right now I'm just writing that dynamic logout button that will go log the user out before reloading the page. I wrote the function (this is actually my entire script.js file):
var scriptLoaded = true;
function confirm_logout()
{
var logout = GetURL('logout_confirm.php');
if(logout == 'true')
{
location.reload(true);
return true;
}
else
{
return false;
}
}
And then I'm loading it up with this:
<script type="text/javascript" src="script/script.js">
var scriptLoaded = false;
</script>
So what I'd like is just put it inside an anchor tag, but for the sake of testing (it wasn't working, and I just wanted to slim it down) I did this:
<script type="text/javascript">
var LoggedOut = false;
if(scriptLoaded == true)
{
LoggedOut = confirm_Logout();
}
document.write(LoggedOut);
</script>
Then I run it in chrome and in the debugging console I get the error: Uncaught ReferenceError: confirm_Logout is not defined (anonymous function).
Help me stack overflow, you're my only hope.
Share Improve this question asked Dec 7, 2010 at 16:30 CrowderSoupCrowderSoup 1645 silver badges16 bronze badges2 Answers
Reset to default 2You need to write confirm_logout
, not confirm_Logout
(lowercase 'l').
<script type="text/javascript">
var LoggedOut = false;
if(scriptLoaded == true)
{
LoggedOut = confirm_logout();
}
document.write(LoggedOut);
</script>
You can't execute Javascript in a script
element if it has a src
it's referencing. Also, you defined confirm_logout
and you are calling confirm_Logout
, capital L
which is why you get confirm_Logout
is not defined.
So I'm pretty new to javascript...right now I'm just writing that dynamic logout button that will go log the user out before reloading the page. I wrote the function (this is actually my entire script.js file):
var scriptLoaded = true;
function confirm_logout()
{
var logout = GetURL('logout_confirm.php');
if(logout == 'true')
{
location.reload(true);
return true;
}
else
{
return false;
}
}
And then I'm loading it up with this:
<script type="text/javascript" src="script/script.js">
var scriptLoaded = false;
</script>
So what I'd like is just put it inside an anchor tag, but for the sake of testing (it wasn't working, and I just wanted to slim it down) I did this:
<script type="text/javascript">
var LoggedOut = false;
if(scriptLoaded == true)
{
LoggedOut = confirm_Logout();
}
document.write(LoggedOut);
</script>
Then I run it in chrome and in the debugging console I get the error: Uncaught ReferenceError: confirm_Logout is not defined (anonymous function).
Help me stack overflow, you're my only hope.
So I'm pretty new to javascript...right now I'm just writing that dynamic logout button that will go log the user out before reloading the page. I wrote the function (this is actually my entire script.js file):
var scriptLoaded = true;
function confirm_logout()
{
var logout = GetURL('logout_confirm.php');
if(logout == 'true')
{
location.reload(true);
return true;
}
else
{
return false;
}
}
And then I'm loading it up with this:
<script type="text/javascript" src="script/script.js">
var scriptLoaded = false;
</script>
So what I'd like is just put it inside an anchor tag, but for the sake of testing (it wasn't working, and I just wanted to slim it down) I did this:
<script type="text/javascript">
var LoggedOut = false;
if(scriptLoaded == true)
{
LoggedOut = confirm_Logout();
}
document.write(LoggedOut);
</script>
Then I run it in chrome and in the debugging console I get the error: Uncaught ReferenceError: confirm_Logout is not defined (anonymous function).
Help me stack overflow, you're my only hope.
Share Improve this question asked Dec 7, 2010 at 16:30 CrowderSoupCrowderSoup 1645 silver badges16 bronze badges2 Answers
Reset to default 2You need to write confirm_logout
, not confirm_Logout
(lowercase 'l').
<script type="text/javascript">
var LoggedOut = false;
if(scriptLoaded == true)
{
LoggedOut = confirm_logout();
}
document.write(LoggedOut);
</script>
You can't execute Javascript in a script
element if it has a src
it's referencing. Also, you defined confirm_logout
and you are calling confirm_Logout
, capital L
which is why you get confirm_Logout
is not defined.
版权声明:本文标题:html - JavaScript: Uncaught ReferenceError: confirm_Logout is not defined (anonymous function) - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745640342a2160707.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论