Entry
How easily swap backcolor and text color(IE5)
How to change button value easily(IE5)
How apply the runtimeStyle to swap backcolor and text color(IE5)
May 17th, 2000 06:18
Hiroto Sekine, Martin Honnen, http://www.all.co.nz/support/jpspell.htm
With IE5: Try below code.
<style>
body {
background: "green";
color: "gold";
}
</style>
var saveFgColor;
var saveBgColor;
function initStatus(){
with(oBody.currentStyle){
saveBgColor = backgroundColor;
saveFgColor = color;
}
}
function swap(){
with(oBody.currentStyle){
var temp1 = backgroundColor;
var temp2 = color;
}
with(oBody.runtimeStyle){
backgroundColor = temp2;
color = temp1;
}
}
function reset(){
var e = event.srcElement;
if (e.value == 'W/B'){
var fgColor = 'black';
var bgColor = 'white';
e.value = 'Resume';
e.title = 'Resume orginal color';
} else {
var fgColor = saveFgColor;
var bgColor = saveBgColor;
e.value = 'W/B';
e.title = 'Reset screen color';
}
with(oBody.runtimeStyle){
backgroundColor = bgColor;
color = fgColor;
}
}
<body OnLoad="initStatus();" id="oBody">
<p>This is sample text.</p>
<p align="center" id="BTN">
<input type="button" title="Swap Text & Background color"
value="T<-->B" name="swap" id="SWAP" OnClick="swap();" /><input
type="button" title="Reset screen color" value="W/B" name="wb"
id="RESET" OnClick="reset();" />
</p>