Upload
max-friel
View
2.503
Download
0
Embed Size (px)
DESCRIPTION
ohihnm
Citation preview
Javascript- Functions
A function is a group of reusable code which can be called anywhere in your program. This stops the need of writing the
same code again and again.
Copy the following code into dreamweaver
<head> <script type="text/javascript">
function sayHello() {
alert("Hello World")
}
</script>
</head>
<body>
<input type="button" onclick="sayHello()" value="Say Hello" />
</body>
When you click on the link, it presents an alert box
Click inside the input type and press spacebar on your keyboard, a selection should appear,
choose onmouseover.
Click inside the input type and press spacebar on your keyboard, a selection should appear,
choose onmouseover.
Enter the following=>
onmouseover=alert("hello")
*click on liveview at the top of dreamweaver and see what happens.
Javascript: for Loop
the for loop makes a list of code copy over and over.
Open a new html page and copy the following into the body tag-
<script type="text/javascript">
var bodyslam= prompt("enter a number");
bodyslam= parseFloat(bodyslam);
if (bodyslam>= 200){
for(bodyslam=5;bodyslam<=5000000;bodyslam=bodyslam+30)
document.write("<PRE>hello </PRE> ");
}
else {
alert("not a high enough number, sorry")
} </script>
The value to enter
How many times it repeats