Custom scripts The browser is programs written on JavaScript performed in the user's browser when loading the page. They allow you to automatically fill in forms, reformat the pages, hide the unwanted contents and embed the desired content to display the contents, change the behavior of the client part of web applications, add controls to the page, etc.
To manage user scripts in Mozillafirefox uses GreaseEmonKey extension; GoogleChrome operae provides user script support tools and features to perform a range of GreaseEmonKey scripts.
Server applications
Applications written in JavaScript can be executed on servers using Java 6 or more late versions . This circumstance is used to build server applications that allow you to process JavaScript on the server side.
In addition to Java 6, there are a number of platforms using existing engines (interpreters) JavaScript to execute server applications. (As a rule, we are talking about re-use Engines previously created to execute JavaScript code in www browsers.)
Practical part
In this course work we will use free program To create a website - a mini-site. In this program, we can prepare the main template of our site, block marking, block sizes, prepare the necessary pages and so on.
For the subject of the site, the official website of IFHIbpp wounds was taken, the site of which was designed for CMSJoomla!
When creating a site, we will analyze the source code of our main HTML page and see what it consists of.
Any page written in HTMLLs should contain the following rows or tags:
1.
This code is present in absolutely in each document, it tells the browser that everything placed between these tags is HTML code. It is the root of the document itself, everything that is currently present behind this tag is no longer included in the document and is not perceived by browsers. At the very beginning of the document, the tag opens and at the very end it must necessarily be closed.
2.
The entire section of this tag contains all technical information Document. Like the previous tag, the head should also be opened and is closed at the end. This information includes a page title, its description, keywords for search engines and encoding. About the encoding is slightly lower.
3.
This tag is included in HEAD, it must be written inside the Head tag. This title tag is mandatory and must be present in each hTML Documente. In addition to this, it is displayed as a browser window title. The length of such a header should not exceed 60 characters. The text of such a header should contain the most complete information that characterizes the content of the page.
After the required Title tag, it is optional, but not a little important META tag. This tag is single. Using this tag, the description is set for the page (Description) and its keywords (Keywords).
In addition, in tag Meta. There may be data about the author of the page and other properties of metadata. You can prohibit indexing the page as a whole for search engines. Put automatic update Pages after 20 seconds or in 5 seconds, followed by the transition to another page.
These META elements may be somewhat, as they can carry absolutely different information. The rest of users when open the page in the browser, do not see all your descriptions, all this remains hidden from the eyes.
5.
Says the browser that all placed between these tags should be displayed in the window of your browser. Here are the main tags that may be present in each document. Body tag serves as the main body of the page, which includes all its contents. This tag is advisable to open and at the end of the document do not forget to close.
6. DOCTYPE element
Each document should also be specified here than the DOCTYPE element. What is it needed and what should be in it. Usually, the people are not much enjoyed by these lines, copy themselves into documents and work calmly. These items say the browser, which version of HTML is used in the document, what is the description of the page that the encoding is used, what keywords are included, who is the author and what is called the page.
They are usually put at the very beginning. There are several options and they all differ from each other, I will write one example, which is used most often. This workpiece can be used as a ready-made pattern. Next will be a clear description of each line, there should be no problems with this.
This is the main page of the site.
The main structure of the site is built. The remaining pages of our site consist of the same major tags with the addition of others that are necessary for beautiful decor, creating tables, creating a menu, connect java scripts and so on.
Now a little words about javascript.
1. In order to implement JavaScript code in an HTML document, it is enough to register it inside the tag. For example:
//Код JavaScript
2. Для того чтобы подключить отдельный файл кода JavaScript, достаточно прописать следующий код:
3. Теперь напишем традиционный первый скрипт, который покажет нам как работает JavaScript. Для этого создадим произвольный html документ следующего содержания:
Начало документа...
document.write("Этот текст написан с использованием JavaScript");
Конец документа
Метод document .write () - предназначен для вывода в документ строки, указанной в качестве параметра данного метода. Если данный метод вызывается в процессе загрузки документа, то он выводит строку в текущем месте.
Теперь перейдем к рассмотрению нашего сайта и кода.
Как я уже говорил, JavaScript можно внедрить в html страницу двумя способами:
1. Разместить код JavaScript внутри тэгов.
2. Подключить отдельный файл JavaScript в котором находится сам код JavaScript.
Рассмотрим первый вариант.
На главной странице нашего сайта в левом блоке расположена ссылка на примеры использования JavaScript. Если перейти по этой ссылке, то первое что мы увидим, это всплывающее окно с надписью: “Всплывающее окно”. Это первый пример JavaScript. Исходный код следующий:
Пример 1. Всплывающие сообщение.
alert("Всплывающее окно");
Ссылка
Здесь основная операция это alert, она выводит модальное окно с сообщением. Посетитель не сможет продолжить работу, пока не нажмет на кнопку "ОК" в модальном окне.
Следующий пример JavaScript это изменение цвета окна при наведении на нее мыши. Исходный код следующий: