How to make the pop-up page

How to make the pop-up page

During creation of the websites pop-up windows as the menu, advertizing texts, etc. are very often used. Besides the compact view allows to save the place on the page. Everything that is necessary - it is to write the correct code.

Instruction

1. Creation of pop-up pages can be made on the basis of JavaScript. Nevertheless, there is simpler option – use of the HTML hypertext markup language and language of the tables CSS. The convenience is that the windows created thus will be supported by the majority of browsers regardless of whether they support JavaScript.

2. The similar code is placed in two terms, in the first line the reference which is responsible for opening of a window, the second line is contained – in fact, and is a pop-up window, the onmouseover attribute says that the cursor type, standard at aiming at a line of the link, will be reflected, onclick indicates that after click the hidden window will become visible:

<a onmouseover= 'this.style.cursor="pointer"' onfocus='this.blur ();' onclick="document.getElementById .style.display='block ('PopUp')' "><span style="text-decoration: underline;">Нажать здесь!</span></a>

3. You will need to specify the window sizes, color and the size of the text, a background and a framework. You can specify all these parameters in the style attribute. Colors it is specified according to the code table rgb. In the standard Paint tool in the Change of Flowers window, in you can find the code of the necessary shade where R – red, G – green, In – blue (blue). So black color has the rgb (0,0,0) code, white rgb(255,255,255), gray rgb(126,126,126).

<div id='PopUp' style='display: none; position: absolute; left: 50px; top: 50px; border: solid black 1px; padding: 10px; background-color: rgb(255,255,225); text-align: justify; font-size: 12px; width: 135px; '> The Message or the text in emerging окне</div>

The display selector with indicated value of none does your window invisible.

4. Now you need to place two of these lines between tags of your <body&gt page; and </body>. After that the pop-up window is ready to work.

5. However at this set you receive constantly open window. So if it is necessary for you that the pop-up window could be closed, add the reference which will be responsible for this action, before the </div&gt tag;:

<br /><div style='text-align: right; '><a onmouseover=' this.style.cursor="pointer" 'style='font-size: 12px;' onfocus='this.blur ();' onclick="document.getElementById .style.display ('PopUp') = 'none' " ><span style="text-decoration: underline;">закрыть</span></a></div>

6. Possibly, you want to make the window emerging not on click as it is described above, and at guidance of the cursor. Then the first line should be written so:

<a onmouseover="document.getElementById ('PopUp') .style.display = 'block' " onmouseout="document.getElementById .style.display ('PopUp') = 'none' " onfocus='this.blur (); '><span style="text-decoration: underline;">наведите mouse сюда!</span></a>

7. Thus, you received the HTML-code of a pop-up window, and are familiar with structure of its drawing up. Everything that it was necessary – to issue appearance and contents that will depend, naturally, on your abilities, the purpose and imagination. But it is necessary to remember that it is the simplest option of creation of a pop-up window. If you own sufficient skill of programming in JavaScript (MooTools, jQuery, Prototype and so forth), you can create more beautiful and interesting page.

Author: «MirrorInfo» Dream Team


Print