Saturday, September 17, 2016

Send viewer back to where they came from

Is your web page under construction or do you not want visitors, or want to make your visitor get a little mad? Copy this script that makes the browser go back to the page that the viewer came from.
<script type="text/javascript">
setTimeout("history.back();", 7000);
</script>

Disable mouse right-click





<script language="JavaScript" Type="text/javascript">
<!--
function popupMsg(theMsg) {
alert(theMsg);
}
//-->
</script>

Change background color depending on time of day

<script type="text/javascript">
var now = new Date();
var hours = now.getHours();

//Keep in code - Written by Computerhope.com
//Place this script in your HTML heading section

document.write('It\'s now: ', hours, '<br><br>');
document.bgColor="#CC9900";

//18-19 night
if (hours > 17 && hours < 20){
document.write ('<body style="background-color: orange">');
}
//20-21 night
else if (hours > 19 && hours < 22){
document.write ('<body style="background-color: orangered">');
}
//22-4 night
else if (hours > 21 || hours < 5){
document.write ('<body style="background-color: #C0C0C0;">');
}
//9-17 day
else if (hours > 8 && hours < 18){
document.write ('<body style="background-color: #616D7E">');
}
//7-8 day
else if (hours > 6 && hours < 9){
document.write ('<body style="background-color: skyblue">');}
//5-6 day
else if (hours > 4 && hours < 7){
document.write ('<body style="background-color: steelblue">');
}
else {
document.write ('<body style="background-color: white">');
}
</script>

Create a random website background color every five seconds

<script type="text/javascript">
function setbackground()
{
window.setTimeout( "setbackground()", 5000); // 5000 milliseconds delay

var index = Math.round(Math.random() * 9);

var ColorValue = "FFFFFF"; // default color - white (index = 0)

if(index == 1)
ColorValue = "FFCCCC"; //peach
if(index == 2)
ColorValue = "CCAFFF"; //violet
if(index == 3)
ColorValue = "A6BEFF"; //lt blue
if(index == 4)
ColorValue = "99FFFF"; //cyan
if(index == 5)
ColorValue = "D5CCBB"; //tan
if(index == 6)
ColorValue = "99FF99"; //lt green
if(index == 7)
ColorValue = "FFFF99"; //lt yellow
if(index == 8)
ColorValue = "FFCC99"; //lt orange
if(index == 9)
ColorValue = "CCCCCC"; //lt grey

document.getElementsByTagName("body")[0].style.backgroundColor = "#" + ColorValue;

}
</script>
<body onload="setbackground();">

Tuesday, November 10, 2015

Make HTML5 Elements Work in Old IE

(function() {
    if (! /*@cc_on!@*/ 0) return;
    var e = "abbr,article,aside,audio,bb,canvas,datagrid,datalist,details,
dialog,eventsource,figure,footer,header,hgroup,mark,menu,meter,nav,
output,progress,section,time,video".split(','),
        i = e.length;
    while (i--) {
        document.createElement(e[i])
    }
})()

Hotlink Script:
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

Detect Internet Explorer

<script type="text/javascript">
    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
//test for MSIE x.x;
        var ieversion = new Number(RegExp.$1)
// capture x.x portion and store as a number
        if (ieversion >= 8)
            document.write("You're using IE8 or above")
        else if (ieversion >= 7)
            document.write("You're using IE7.x")
        else if (ieversion >= 6)
            document.write("You're using IE6.x")
        else if (ieversion >= 5)
            document.write("You're using IE5.x")
    } else
        document.write("n/a")
</script>

Detect Javascript On/Off, With Notification

<script type="text/javascript"> document.write("Welcome, you have Javascript on.") </script> <noscript>JavaScript is off. Please enable to view full site.</noscript>

If JavaScript is on the user gets a welcome message. If off, the user is instructed to turn it on.

How to Put Google Adsense Below Post Title in Blogger?

Adsense is used by  majority  of expert bloggers for their website monetization because it is a cookie based contextual advertising syste...