The document object is on top of the DOM hierarchy, just below the window object. Because of this, the document object is the starting point for most JavaScript objects. Here are some example scripts : Add to Favorites (IE) : If you have a web site and want to make it easy for your visitors to add your site to the favorites, here is a script for that purpose (put it in the <head> section) : <script>
var url="http://dinkosta.tripod.com"
var title="DinkostaOnline"
function addfav(){
if (document.all)
window.external.AddFavorite(url,title)
} </script> Now you have to create a link on which the user can click in order to add the site to the favorites, for example : <a href="javascript:addfav()">Add to Favorites</a>
No right-click : Web site owners often would like to protect their images or other content, but can't do it effectivelly. The following script can provide protection only against people who are not very familiar with their browser, but at least it's some kind of content-protection and it's very simple. The script that disables the right-click on a page goes like this (put in <head> section) : <script>
function norightclick(){
if(event.button==2){
alert('Your text here.')}}
document.onmousedown=norightclick
</script> Click on this page to see example .
N e x t
|