Jump to content

Function Not Found


absorr

Recommended Posts

<!DOCTYPE html><html>    <head>	    <title>Nova Skin Lite</title>	    <script type="text/javascript">		    function steve() {			    document.getElementById('edit').innerHTML = '<iframe src=\"http://minecraft.novaskin.me/lite#http://www.minecraft.net/images/char.png\" width=\"100%\" height=\"800\">ERROR CODE: I ######ed up</iframe>';		    }		    function userSkin() {  var user = document.skin.user.value			    document.getElementById('edit').innerHTML = '<iframe src=\"http://minecraft.novaskin.me/lite#'user'\" width=\"100%\" height=\"800\">ERROR CODE: I ######ed up</iframe>';		    }	    </script>    </head>    <body>	    <div id="edit"><iframe src="http://minecraft.novaskin.me/lite#http://www.minecraft.net/images/char.png" width="100%" height="90%">ERROR CODE: I ######ed up</iframe></div>	    <form name="skin">		    Load User Skin: <input type="text" name="user" />		    <input type="button" value="Submit" onClick="javascript:userSkin();" />		    <input type="button" value="Steve (default)" onClick="javascript:steve();" />	    </form>    </body></html>

When I click the button (either one) it does not work. In the chrome JS console it says "Uncaught ReferenceError: steve is not defined"

Link to comment
Share on other sites

I can't see anything in your code that could cause that. Are there any other errors appearing in your code? If a function has an error in it, it won't be constructed when the page runs.

Link to comment
Share on other sites

The only thing I can see that cause it to fail is the 'user' variable between link document.getElementById('edit').innerHTML = '<iframe src=\"http://minecraft.novaskin.me/lite#'user'\" width=\"100%\" height=\"800\">ERROR CODE: I ######ed up</iframe>'; should be document.getElementById('edit').innerHTML = '<iframe src=\"http://minecraft.novaskin.me/lite#'+user+'\" width=\"100%\" height=\"800\">ERROR CODE: I ######ed up</iframe>';

Link to comment
Share on other sites

Guest So Called

Think of my comment as asking a question rather than supplying an answer. Doesn't this statement need to be terminated?

var user = document.skin.user.value

Like with a semicolon?

Link to comment
Share on other sites

Javascript doesn't require semicolons, if there's not one then it generally assumes the statement ends at the end of the line unless the statement requires something else. It would understand this correctly, for example, because the plus operator indicates there's something else to the statement: var str = 'first line' +'second line'

Link to comment
Share on other sites

Guest So Called

Okay, thank you for the JavaScript lesson. I came into writing JavaScript (and PHP) from writing C and C++ where of course lines must be terminated. I'm surprised that JS doesn't need that, doesn't care. It is good to write "neat" code (sometimes called "tidy") because your bugs are easier to spot, and the code is easier to maintain (particularly if somebody but the author has to maintain it).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...