Best way to read/set IE options?

2019-08-28 18:02发布

问题:

What is the best way to read and/or set Internet Explorer options from a web page in Javascript? I know that these are in registry settings.

For example, I'm using the JavaScript Diagram Builder to dynamically generate bar charts within a web page. This uses the background color in floating DIVs to generate the bars. I would like to be able to read the browser setting for printing background colors, and if not checked, either warn the user that the colors won't print, or programatically select this option.

EDIT: As I think about the products that do something similar, I think they mostly just test whether Java or JavaScript or Cookies are disabled, which can be done without reading the registry.

So I guess the consensus is that what I want to do shouldn't be attempted.

回答1:

Web pages have no business reading users' settings, therefore there is no interface for this.



回答2:

You can style the bars using a whopping left border instead of using a background colour.

Like this:

<style>
    div.bar
    {
      width:1px;
      border-left:10px solid red;
    }
</style>
<div class="bar" style="height:100px"></div>

Obviously depends on the versatility of the product you're using. But I don't see why it would hurt to do this in a print style sheet at least.



回答3:

This sounds like it would be a big security hole, one that the IE team would keep nailed very shut