Just some tips that you should follow if you plan on selling your websites...
1. As djr33 said, always comment your code to make it easier to see what it does. You can never have to many comments... actually you can, but that's not the point. Make them easy to read, keep them nice and short (don't write a five page essay on what the line
var x = 10; does.
2. Always indent your code. You may not like doing it at first, but it really makes the code easier to follow. Also, always indent your code the same way (build a pattern). If you're not sure what indenting is, just say!
3. Always name your variables sensibly. Say you have a field in a form called username. Then if you're doing validation or something like that, it's a lot easier to read if you name the variable username instead of chucknorrisiscool.
4. Same as above but for functions().
5. Try and keep your coding nice and neat. Don't leave random spaces everywhere and try to keep to a nice pattern of html tags.
HTML Code:
<html><head><script type="text/javascript">alert("hi");
function doNothing(elem) {
if(elem == 1) { alert("elem = 1");
} else {
alert("elem != 1"); }
</script><title>WELCOME TO MY EPIC WEBPAGE</title>
</head><body><div>MOOO!</div><h1>Hey Guys and Gals</h1>
<a href="#" onclick="alert('fooled ya!');">
CLICK ME
</a></body>
</html>
It's hard to read and has no structure to it
HTML Code:
<html>
<head>
<script type="text/javascript">
alert("hi");
function doNothing(elem) {
if(elem == 1) {
alert("elem = 1");
} else {
alert("elem != 1");
}
</script>
<title>WELCOME TO MY EPIC WEBPAGE</title>
</head>
<body>
<div onclick="doNothing('1')">MOOO!</div>
<h1>Hey Guys and Gals</h1>
<a href="#" onclick="alert('fooled ya!');">CLICK ME</a>
</body>
</html>
Much better! I also indented the functions (every thing rapped in a {} is tabbed foward once).
Since you're using xhtml, you probably won't have a problem with things like <script> and <SCRIPT>.
Hope you can use these suggestions (or are already doing them). (Sorry, little bit off topic, but I wanted to be helpfull
)
P.s. I do so love Jajascript
!
Bookmarks