注: 獲取Dom元素的Style數組中的指定Style元素
function elementGetStyle(element, style) {
var value = null;
if (element.style) {
value = element.style[style];
}
if (!value ) {
if (document.defaultView && document.defaultView.getComputedStyle) {
var css = document.defaultView.getComputedStyle(element, null);
value = css; ;
} else if (element.currentStyle) {
value = element.currentStyle[style];
}
}
/**需要DGF嗎?
if (window.opera && ['左', '上', '右', '下'].include(style))
if (Element.getStyle(element, '位置') == '靜態')值='自動';*/
return value == 'auto' ? null : value;
}
注:選定的Dom元素以color顏色高亮0.2s
function UiWebhighlight(element,color) {
if!!! element) {return}
var highLightColor = "yellow";
if (color) {highLightColor = color}
if (element.originalColor == undefined) { // avoid picking up highlight.originalColor == undefined) { // avoid picking up highlight> .originalColor = elementGetStyle(element, "background-color");
}
elementSetStyle(element, {"backgroundColor" : highLightColor});
window.setTimeout(functiontry> {
window.setTimeout(functiontry> {
window.setTimeout(function (try)>
//if element is orphan, probably page of it has already gone, so ignore
if (!element.parentNode) {
return;
}
elementSetStyle( ": element.originalColor });
} catch (e) { } // DGF unhighlighting is very dangerous and low priority
}, 200);
}