Unit 14. Other Features (III)


Adding external code

 

Sometimes we would like to introduce into our pages some things we have seen published over the internet.

You can see the Source code of these pages through View menu of Internet Explorer, and then the Source code option, or displaying the page contextual menu by right-clicking on it and then selecting the View source code option. By doing this you can consult the code that has been used to build the page, and therefore use it for your own pages.

 

Viewing the font code is useful to check the page's structure, the use of behaviors (programmed in JavaScript code), and other sets of JavaScript routines.

For example, click here to open a page in which there is an effect in the browser's status bar, that shows a marquee, whose text is JavaScript CODE - DREAMWEAVER 8 TUTORIAL- TEACHERCLICK

If you look at the page's source code you will find the JavaScript code used to create that effect in the status bar. The code is the following:

<SCRIPT language=JavaScript>

<!--

strcnt=0;

mensaje=" JavaScript CODE - DREAMWEAVER 8 TUTORIAL- TEACHERCLICK ";

function scroller()

{

window.status=mensaje.substring(strcnt++,mensaje.length+1);

if(strcnt>mensaje.length)

strcnt=0;

setTimeout("scroller()",200);

}

//-->

</SCRIPT>

This code has to go between the <HEAD> and </HEAD> labels, and add onload="scroller()" inside the <BODY> label, resulting in:

<BODY onload="scroller()">

This code is not too complicated, and you could add it to your own pages without problems in order to show the messages you want.

On many occasions it can be difficult to understand the code, and even more so if you don't have a programming language knowledge.

If you don't know the code, you can make the copy of the mistaken or incomplete JavaScript code, insert it in a erroneous place in the HTML code, etc.

 

The important thing to remember about JavaScript functions, is that they are between the lines.

<HEAD> ... <SCRIPT language=JavaScript> <!--

and

//--> </SCRIPT> ... </HEAD>

 

  Ir a la página anterior Índice del curso  Ir a la siguiente página  

Page. 14.3