- document.write() is. - why? Basically you can use both. - you can see that we used both double and single quotes. - This means you can also write. - You can create a similar popup window with the prompt() method.. - document.write("Welcome to my homepage!<br>");. - document.write("This is JavaScript!<br>");. - You can see that we write myFunction() three times. - You can see that the function does certain calcula- tions. - With the help of JavaScript you can easily manipulate the objects. - You can see the name of the objects in the hierarchy. - This means you can access the first textelement throu- gh:. - If the input is ’Stefan’ the command alert("Hi ". - You can see in our HTML-code that we wrote for example:. - For example you can write a new string to a textelement.. - document.write("The background color is: ");. - document.write("The text on the second button is: ");. - So you can for example create two frames. - You can see that we use the rows property in the <frameset>. - You can also write . - You can set the size of the border through the border property in the <frameset>. - Now we want to have a look at how JavaScript ’sees’ the frames in a browser window. - For example you can write:. - You can see that we write ’first.htm’ inside the brackets. - There you can see that we write url inside the brackets. - You can use this function for example:. - You can either load a new do- cument (for example a HTML-document) to the new window or you can create new documents (on-the-fly). - You can control the appearance of the new window. - Besides that you can specify the size of the win- dow. - You can find an explanation of these properties in the JavaScript 1.2 guide. - You can just access the window through this variable. - You can close windows through JavaScript. - myWin.document.write("<html><head><title>On-the-fly");. - myWin.document.write("</title></head><body>");. - myWin.document.write("<center><font size=+3>");. - myWin.document.write("This HTML-document has been created ");. - myWin.document.write("with the help of JavaScript!");. - myWin.document.write("</font></center>");. - myWin.document.write("</body></html>");. - You can see that we open a new browser window first. - You can see that we write normal HTML-tags to the document. - parent.frame2.document.write("Here goes your HTML-code");. - vrml.document.close();. - mean? It’s the MIME-type of the file we want to create. - You can see that the function call created by the Write! button looks like this:. - You can see that we defined the function statbar() like this:. - You can see that we are adding 1900 to the year. - You can see that the function clock() is called with the onLoad event-handler in the <body>. - Since JavaScript 1.1 (Netscape Navigator 3.0) you can use the Array-object. - document.write(myArray[i. - You can see that we are using myArray[i] inside the for-loop. - document.write(myArray[0. - document.write(myArray[1. - document.write(myArray[2. - You can now create an array with:. - You can use this code if you leave this message. - You can only do this through CGI. - With the help of the focus() method you can make your form a little bit more user-friendly. - You can do this with the following piece of script:. - With the help of the Image-object you can change images on a web-page. - you can address it through document.myImage or document.images["myImage"].. - if (document.images[pics[i][2. - You can see that we call the preload() function like this:. - It’s not the quantity of images that makes your web-page look good - it’s the qua- lity. - You can also hide objects.. - You can use the following pro- perties:. - The name of the layer. - You can see that we define two layers with the <layer>. - You can see that we use the property z-index. - You can see the text through the image because I used a transparent background (gif89a format).. - In order to access the bottommost layer you can write document.layers[0]. - if (document.layers["myLayer"].visibility. - You can see that this function accesses the property visibility of the layer-object myLayer. - You can assign new values to these properties in order to set the position of the layer. - document.layers["myLayer2"].left= 200;. - document.layers["myLayer2"].left= pos;. - You can see that we are using onLoad inside the <body>. - You can use the HTML-property clip like this:. - You can see in the code that the image is called davinci. - You can see three buttons. - You can see that we define two layers inside the parentLayer. - Again you can see how we have to access the nested layer:. - Time to have a look at one of the new features of the Netscape Navigator 4.x: the event model of JavaScript 1.2. - You can see that some new events have been implemented. - If you for example have a button object you can define the event handler like this:. - You can click it somewhere. - You can see that we are using the event handler onClick inside the <a>. - You can see that we do not define an event handler inside the <a>. - You can see that we use return true. - of the mouse event. - You can click somewhere inside the browser window. - You can see that this function takes one argument (we call it e). - You can see that the code is almost the same as in the last example:. - dragObj[0]= document.layers["layer0"];. - dragObj[1]= document.layers["layer1"];. - dragObj[2]= document.layers["layer2"];. - You can see that we define three layers in the <body>. - You can see that we use the same code as shown above in order to capture the mouse events:. - You can solve this problem by changing the order of the layers in the startDrag() function.. - You can place anything inside
Xem thử không khả dụng, vui lòng xem tại trang nguồn hoặc xem
Tóm tắt