Tuesday, December 14, 2010

Tuesday, December 14th

This is my first hello world program using javascript:



document.writeln('Hello, world!');



Here is another program, I can tell that working with JavaScript and posting it on this blog might be a problem, we may have to end up switching to Google Documents





The alert() method displays a simple alert dialog box whose content is whatever text is passed as a parameter to the method.



<html>
<head>
<title>My First Script</title>
<style type="text/css">
.highlight {font-weight:bold}
</style>
</head>

<body>
<h1>Let's Script</h1>
<hr>
<script type="text/javascript">
document.write("This browser is version " + navigator.appVersion);
document.write(" of " + navigator.appName + ".");
</script>
</body>
</html>


Here is another JavaScript tutorial using deferred scripts In this tutorial, a javaScript function is called upon to loan right after the page loads.




<html>

<head>
<title>An onload script</title>

<script type="text/javascript">
function done() {
alert("The page has finished loading.");
}
</script>

</head>

<body onload="done()">
Here is some body text.
</body>

</html>



Here is another tutorial on running a script from User Action



<html>
<head>
<title>An onclick script</title>
<script type="text/javascript">
function alertUser() {
alert("Ouch!");
}
</script>
</head>

<body>
Here is some body text
<form>
<Input type="text" name="entry">
<input type="button" name="oneButton" value="Press Me!" onclick="alertUser()">
</form>
</body>
</html>



OK this is going to be my last JavaScript Tutorial for today, and for now I am going to go back to working on vb.net



<html>
<head>
<title>Window Opener and Closer</title>
<script type="text/javascript">
var newWindow
function makeNewWindow() {
newWindow = window.open("","","height=300,width=300");
}
function closeNewWindow() {
if (newWindow) {
newWindow.close();
newWindow = null;
}
}
</script>
</head>

<body>
<form>
<input type="button" value="Create New Window" onclick="makeNewWindow()">
<input type="button" value="Close the Window" onclick="closeNewWindow()">
</form>
</body>
</html>



Here is a tutorial on using parameter arrays




Module Module1

Sub Main()
AnyNumberArgument()
AnyNumberArgument(3, 4)
AnyNumberArgument(8, 2, 3, 7, 10)
Console.ReadLine()
End Sub

'use paramArray to create a variable-length parameter list
Sub AnyNumberArgument(ByVal ParamArray array1 As Integer())
Dim i, total As Integer
total = 0

If array1.Length = 0 Then
Console.WriteLine("Received 0 arguments.")
Else
Console.Write("The total of ")
For i = 0 To array1.GetUpperBound(0)
Console.Write(array1(i) & " ")
total += array1(i)
Next
Console.WriteLine("is {0}.", total)

End If
End Sub
End Module


Here is another tutorial on Parameter Arrays



Sub displayVals(ByVal ParamArray intVals() As Integer)
Dim i As Integer
For Each i In intVals
Console.WriteLine("Display Vals {0} ", i)
Next i

End Sub

Sub main()
Dim a As Integer = 5
Dim b As Integer = 7
Dim c As Integer = 9
Console.WriteLine("Calling with three Integers")
displayVals(a, b, c)

Console.WriteLine("Calling with four integers")
displayVals(5, 6, 7, 8)

Console.WriteLine("Calling with an array of four integers")
Dim explicitArray() As Integer = {5, 6, 7, 8}
displayVals(explicitArray)

Console.ReadLine()

End Sub

No comments: