views:

256

answers:

3

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.

A: 

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

sblundy
For setting options, I agree; but for just reading options, where's the risk? Also, some products already do this.
Ken Paul
Can you name some legitimate products Paul that do this? If javascript were capable of reading "some" registry settings, then wheres the chinese-walls to prevent it from reading "all" registry settings. Plenty of installed apps keep sensitive local data (password hashes, crypt keys etc)...
Eoin Campbell
(contd.) ...in the registry and it'd be a pretty massive security hole to allow any random webpage execute javascript on the client machine which could read your registry and then send that data back to the source
Eoin Campbell
I learned quite a long time ago to never say this about IE - you'd be surprised some of the things you can do w/the right ActiveX object
Peter Bailey
@BaileyP. touché :)
Eoin Campbell
+5  A: 

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

Diodeus
+1  A: 

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.

Lee Kowalkowski
Of course, if your bar chart is on the other axis, it'll need to be a top border!
Lee Kowalkowski
This is a complex third-party package, so I'm reticent to try to tinker with it. I will make this suggestion to the author, however.
Ken Paul