#737 bug
Tim Fluehr

IE "Permission Denied" error with getStyle

Reported by Tim Fluehr | July 14th, 2009 @ 11:04 PM

Please let me know if you have any questions since this one is kind of complicated to explain/dupe.

IE will throw a "Permission Denied" error when using Element.getStyle when reading a style property that is specified in an external css file that is loaded from a different domain then your html page AND there is a charset Response header set on the css file AND IE does NOT support the property you are trying to read.

For example if in your css file you have the multiple different ways of specifying opacity for different browsers (meaniing you have opacity: 0.6; spefified). Then if you try element.getStyle('opacity') a "Permission Denied" error will be thrown when Prototype executes value = element.currentStyle[style]; in the getStyle function.

It is also an issue for any other css property that is specified but IE does not support. element.getStyle('badProperty') will throw the error if 'badProperty' is specified in the css file. But will not throw the error is 'badProperty' is not specified.

I am attaching a patch file with a fix I came up with. Not sure if there is a better way, but this seems to be working for me.

Again, this is a little confusing to explain so please let me know if you have any questions.

Comments and changes to this ticket

  • Tim Fluehr

    Tim Fluehr July 14th, 2009 @ 11:05 PM

    • Tag set to getstyle, ie
  • Juriy Zaytsev

    Juriy Zaytsev July 19th, 2009 @ 08:05 AM

    • State changed from “new” to “bug”

    I'm not sure if fixing this relatively rare case is worth the performance hit (introduced by try/catch). It might make more sense to document this glitch. If we do decide to fix it, than the patch needs accompanying unit tests.

    Could you explain why stylesheet is served with charset response header?

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 04:05 AM

    • Tag cleared.

    [not-tagged:"ie" not-tagged:"ie6" not-tagged:"ie7" not-tagged:"ie8" bulk edit command]

  • T.J. Crowder

    T.J. Crowder November 16th, 2009 @ 04:50 PM

    [responsible:none bulk edit command]

  • Nick Wing

    Nick Wing January 25th, 2010 @ 09:46 PM

    We ran into this bug as well. I came up with an alternate patch that will solve a majority of cases and can only improve performance.

    Since opacity is the likely culprit in a majority of cases, just move the currentStyle line below the opacity special case treatment. Like so:

    var value = element.style[style];
    
    if (style == 'opacity') {
      if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/))
        if (value[1]) return parseFloat(value[1]) / 100;
      return 1.0;
    } else if (!value && element.currentStyle) value = element.currentStyle[style];
    
  • Tobie Langel

    Tobie Langel March 1st, 2010 @ 12:41 AM

    • Tag set to section:dom

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins

Attachments

Pages