1.

Solve : Javascript alert issue.?

Answer»

Why does this work?
Code: [Select]<html>
<head>
<script type="text/javascript">
function ale_rt()
{
alert("I am an alert box!");
}
</script>
</head>
<body>

<input type="button" onclick="ale_rt()" value="Show alert box" />

</body>
</html>But not this?
Code: [Select]<html>
<head>
<script type="text/javascript">
function alert()
{
alert("I am an alert box!");
}
</script>
</head>
<body>

<input type="button" onclick="alert()" value="Show alert box" />

</body>
</html>Same with the confirm command.You cannot give any function the same name as a predefined JS function, like alert, confirm, and a bunch more.Ok, yea I GUESSED that might be it, I'll have to find a list of predefined functions then...You'll be able to guess them after a while. Here: http://javascript.about.com/library/blreserved.htmAlright thanks. ANOTHER question... how do I go about actully practicing Javascript? Like I'm going through the tutorial at w3schools, but that doesn't mean I actually "know it" or can use it efficiently.

I need some way to practice it... any suggestions?Ahhh......

* thinks *

Do you EVER go to a site and wonder, how did they do that?
Well the best way to learn is to CHEAT - look at source code of the site. USUALLY CTRL+U.haha okay



Discussion

No Comment Found