<HTML><HEAD>
<title>Управление цветом</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<!-- ///////////////////////////////// //////////////////////////////////////////
Cut & Paste JavaScript
Copyright 1996, IMA STUDIOS, Inc.
This code may not be resold.
This Copyright notice must be included
on every document that contains this code.
be included somewhere on your document.
////////////////////////////////////// ///////////////////////////////////// -->
</HEAD>
<body bgcolor="white" text="black" link="red" alink="purple" vlink="red">
<code><b>
Это пример отлично демонстрирует как можно
можно дистанционно управлять другим окном
<SCRIPT LANGUAGE="JavaScript">
<!--
var OldUrl = "none";
var MyColor = "none";
var DsplyStr= "Manu";
var TimeWait = 1000;
var TimeDelta = 100;
var Tid;
function initArray() {
this.length = initArray.arguments.length;
for (var i = 0; i < this.length; i++) {
this[i+1] = initArray.arguments[i];
}
}
var BkgdColorSet = new initArray(
7,
"black",
"gray",
"tan",
"blue",
"purple",
"yellow",
"green",
"brown",
"teal",
"pink",
"aliceblue",
"antiquewhite",
"salmon",
"sandybrown",
"seagreen",
"seashell",
"sienna",
"silver",
"skyblue",
"slateblue",
"slategray",
"snow",
"springgreen",
"tan",
"teal",
"thistle",
"tomato",
"turquoise",
"violet",
"wheat",
"white" ,
"whitesmoke",
"yellow",
"yellowgreen"
)
function IncrTimeWait () {
TimeWait = TimeWait + TimeDelta;
DsplyStr = "" + TimeWait + "ms";
this.document.PageTrack.Monitor.value = DsplyStr;
}
function DecrTimeWait () {
if (TimeWait > TimeDelta) {
TimeWait = TimeWait - TimeDelta;
DsplyStr = "" + TimeWait + "ms";
this.document.PageTrack.Monitor.value = DsplyStr;
} else {
this.alert("You can't let TimeWait = 0 !");
}
}
function PageMani(color) {
this.IMAWin.document.bgColor = color;
}
function PageOrig() {
this.IMAWin.location = this.IMAWin.location;
}
function Cycle() {
// A simple way to know if this automator is still alive.
if (DsplyStr == "Auto") {
DsplyStr = "" + TimeWait + "ms";
} else {
DsplyStr = "Auto";
}
this.document.PageTrack.Monitor.value = DsplyStr;
CurUrl = "" + this.IMAWin.location;
if (CurUrl != OldUrl) {
OldUrl = "" + this.IMAWin.location;
PageMani(MyColor);
}
// sleep().
Tid = setTimeout("Cycle()",TimeWait);
}
function StartCycle() {
if (MyColor == "none") {
this.alert("Please select a color.");
} else {
// avoid more than one cycle().
clearTimeout(Tid);
DsplyStr = "Auto";
PageMani(MyColor);
Cycle();
}
}
function StopCycle() {
if (MyColor == "none") {
this.alert("Please select a color.");
} else {
clearTimeout(Tid);
DsplyStr = "Manu";
PageMani(MyColor);
this.document.PageTrack.Monitor.value = DsplyStr;
}
}
//-->
</SCRIPT>
<CENTER>
<FONT COLOR="black">
</FONT>
</CENTER>
<SCRIPT LANGUAGE="JavaScript">
<!--
document.write("");
document.write("</CENTER>");
document.write("</FORM>");
document.write("<FORM NAME='ColorSlct'>");
for (var i = 1; i < BkgdColorSet.length; i++) {
mono = '"' + BkgdColorSet[i+1] + '"';
document.write(
"<INPUT TYPE='radio' NAME='ColorSlct' onClick='MyColor="
+ mono
+ ";PageMani(MyColor)'><FONT COLOR='black'>"
+ mono.substring(1, mono.length-1)
+ "</FONT><BR>"
);
}
document.write("</FORM>");
document.write("");
document.write("<FORM>");
document.write("");
document.write(
"<INPUT TYPE='button' style=\"width:330\" VALUE='Вернуть оригинальный цвет
' onClick='PageOrig();self.close()'>"
);
document.write("");
document.write("</FORM>");
document.write("");
//-->
</SCRIPT>
</BODY></HTML>
|