Monday, November 24, 2008

JavaScript Tutorials Part-II

  • Script for watercolor logo:


<script language="JavaScript1.2">

if (document.all||document.getElementById)

document.body.style.background="url('logo1.jpg') white center no-repeat fixed"

script>

With in the body tag code.

  • Script for Domain Info:


<script type="text/javascript">

document.write(document.domain+'
'
);

document.write(document.referrer +'
'
);

document.write(document.URL +'
'
);

document.write("This document contains: " + document.forms.length + " forms."+'
'
);

document.write("This document contains: " + document.images.length + " images."+'
'
);

document.write("This document contains: " +document.anchors.length+ " anchors."+'
'
);

document.write(document.title);

script>

  • Script for Say about mouse click:


<body onmousedown="whichButton(event);">

<script type="text/javascript">

function whichButton(event)

{

if (event.button==2)

{

alert("You clicked the right mouse button!");

}

else

{

alert("You clicked the left mouse button!");

}

}

script>

  • Script for Ctrl+C:


<script language="javascript" type="text/javascript">

function onKeyDown() {

// current pressed key

var pressedKey = String.fromCharCode(event.keyCode).toLowerCase();

if ((event.ctrlKey && (pressedKey == "c")) )

{ // disable key press porcessing

event.returnValue = false;

}

} // onKeyDown

script>


  • Script for Disable Right Click:


<script language="javascript" type="text/javascript">

document.onmousedown=disableclick;

status="Right Click Disabled";

function disableclick(e)

{

if(event.button==2)

{

alert(status);

return false;

}

}

script>


  • Script for Disable Selection in WEB Page:


<body onkeydown="onKeyDown()" oncontextmenu="return false" ondragstart="return false" onselectstart="return false">


  • Script for BookMark:


function addBookmark(title, url) {

if (window.sidebar) { // firefox

window.sidebar.addPanel(title, url,"");

}

else if( document.all ) { //MSIE

window.external.AddFavorite( url, title);

}

else {

alert("Sorry, your browser doesn't support this");

}

}

No comments: