A competently developed Java script is a half of a competently developed site.
There are categories of web sites, which contain numerous references (links) to other resources such as directories of references, various lists (for example, price lists), and photo galleries. Viewing such pages, visitors often use clicking (Click) the right mouse button and select the menu option "Open a new window".
So, once loading your page with links, a visitor can use it for a long time "bringing" you no shows of web sites. Some web sites even specially block clicking the right button with the simplest Java script:
<script LANGUAGE="JavaScript">
function right(e) {
if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2)) return false;
else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) { alert("Right button disabled");
return false;
} return true;
} document.onmousedown=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
window.onmousedown=right;
</script>
In this case, clicking the right mouse button does not open a new window but shows a window with the warning notice: "Right button disabled".
In order to view references, a visitor of such site has every time to return to your page with the list of references. For very interesting pages (MP3, games, freeware, photos, etc.), this does not result in loss of visitors but at the same time essentially increases the number of web site shows.
However, such Java script is too primitive. It does not enable to use the interest of visitors more effectively. This web site promotion guide shows how to develop Java script so that you would be able to increase essentially the number of shows of your web pages. This Java script is upgraded as follows:
<script LANGUAGE="JavaScript">
function right(e) {
if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2)) return false;
else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) {
window.open('http://direct.yandex.ru','javascript_1'); return false;
return false;
} return true;
} document.onmousedown=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
window.onmousedown=right;
</script>
Here, if a visitor clicks the right mouse button to some reference, instead of loading the link, the new window will provide transition to site http://direct.yandex.ru/ This visitor will have to open references in the same window (or to switch off use of Java script in browser that is not suitable).
However, neither this script uses the options by 100 %. Why should a visitor be referred every time to the same page? And what if the page addresses are changed? There are two options: to make the whole page in the script form (Perl or PHP) and to change the address or transition for each loading or to upgrade Java script in order to change page addresses stochastically from the list.
<script LANGUAGE="JavaScript">
function right(e) {
var rand = Math.floor(Math.random() * 10);
if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2)) return false;
else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3) && rand == 0) { window.location="http://wmgamer.narod.ru/";
return false;
} else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3) && rand == 1) { window.location="http://slavyan14.narod.ru/";
return false;
} else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3) && rand == 2) { window.location="http://leugen.narod.ru/";
return false;
} else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3) && rand == 3) { window.location="http://weber.h17.ru/";
return false;
} else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3) && rand == 4) { window.location="http://webdoc.pochta.ru/";
return false;
} else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3) && rand == 5) { window.location="http://getfreepage.narod.ru/";
return false;
} else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3) && rand == 6) { window.location="http://sitebesplatno.by.ru/";
return false;
} else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3) && rand == 7) { window.location="http://icq2.by.ru/";
return false;
} else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3) && rand == 7) { window.location="http://dosug51.ucoz.ru/";
return false;
} else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3) && rand == 9) { window.location="http://ru.mysoftreview.com/our_partners.html";
return false;
} else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3) && rand == 10) { window.location="http://bume-rang.by.ru/prog_prog.htm";
return false;
} else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3) && rand == 11) { window.location="http://www.marketer.ru/node/1947/print";
return false;
} return true;
} document.onmousedown=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
window.onmousedown=right;
</script>
Use of Java script for development of web sites has some specific features. In general, Java script in Internet Explorer can be "hardly" upgraded in cache. So if you place this script in a web site and load the same then, most probably, the same site will be loaded. In order to verify that the script gives different transition addresses, load the web site in a new copy of browser (run it again rather than open another window in the browser!). Then transition will be provided to a different address. Therefore, it is desirable to supplement the web site with such script also with the tags controlling update of the browser cache. However, you should be attentive. If your web site has a rather large size (70 to 100 kbytes) and loaded slowly, then its loading beyond the browser cache will be provided very long by each clicking the right button. Real use of sites (size up to 70 kbytes of only HTML code, not including figures) demonstrated that there is no need in cache control. During the same day or on the following day, visitors visit these sites and in this case, as a rule, a different page is loaded from the list.
Nevertheless, see below the examples of browser cache control.
<meta http-equiv=pragma content=no-cache>
Prohibited document caching. In this case, the document will not be cached either by proxy server or by browser. If you specify private, then the document will be cached with browser but it will not be cached with proxy server.
<meta http-equiv="Cache-Control" content="private">
Using the cache control operator, you can determine the maximum caching period of the certain document with max age:
<meta http-equiv="Cache-Control" content="private,max-age=60">
In this case, document caching is provided with browser but not provided with proxy server for the period of 60 seconds.
Efficiency statistics. - The efficiency of using such scripts is exclusively high if scripts are placed in the frequently visited resources (MP3, jokes, photo galleries, guide books, etc.). Application of such scripts enables to provide visitors with new resources, which can be potentially interesting. If you use Perl or PHP, these problems can be solved through the server scripts. However, Java script is more universal and can be used in any hosting.
"The web sites promotion and search engines optimization" - free ebook.
You may copy this guide free of charge and place the same in your web sites.