Wednesday, April 16, 2008

Java Script References

1. close form after some time intervals

setTimeout('self.close()',5000);

-- > where self.close() close the form and 50000 is 5 seconds so, form is closed after five seconds

2. Refresh Parent Window after closing Popup window

function refreshParent()
{
window.opener.location.href = window.opener.location.href;
if (window.opener.progressWindow)
{
window.opener.progressWindow.close()
}
window.close();
}

3. Set URL as Homepage

function setHome()
{
document.body.style.behavior='url(#default#homepage)';
document.body.setHomePage("http://www.yoursitename.com");
}

4. Display Digital Clock

function clock()
{
var digital = new Date();
var hours = digital.getHours();
var minutes = digital.getMinutes();
var seconds = digital.getSeconds();
var amOrPm = "AM";
if (hours > 11) amOrPm = "PM";
if (hours > 12) hours = hours - 12;
if (hours == 0) hours = 12;
if (minutes <= 9) minutes = "0" + minutes; if (seconds <= 9) seconds = "0" + seconds; var a = digital.getMonth(); var b = a + 2 - 1; dispTime = +" "+hours + ":" + minutes + ":" + seconds +''; document.getElementById('Span1').innerHTML = dispTime; setTimeout("clock()", 1000); } window.onload=clock;

5 Disable right clicking on your site to prevent people from stealing your images and code!

function click(e) {if (document.all) {if (event.button == 2) {alert(message);return false;}}if (document.layers) {if (e.which == 3) {alert(message);return false;}}}if (document.layers) {document.captureEvents(Event.MOUSEDOWN);}document.onmousedown=click;

No comments: