The following function will convert any colour value (rgb, named colours, etc) to the hex equivalent in MSIE:

function toHex(color) {
  var body  = createPopup().document.body,
      range = body.createTextRange();
  body.style.color = color;
  var value = range.queryCommandValue("ForeColor");
  value = ((value & 0x0000ff) << 16) | (value & 0x00ff00) | ((value & 0xff0000) >>> 16);
  value = value.toString(16);
  return "#000000".slice(0, 7 - value.length) + value;
};
For other browsers you can use getComputedStyle() so that is already a solved problem.

相关文章:

  • 2021-11-09
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
猜你喜欢
  • 2021-11-27
  • 2022-12-23
  • 2021-10-28
  • 2022-03-02
  • 2021-12-06
  • 2022-01-30
  • 2021-05-25
相关资源
相似解决方案