Closed Bug 1443872 Opened 8 years ago Closed 9 months ago

Cannot get background property of an element when loaded in an iframe

Categories

(Core :: CSS Parsing and Computation, defect, P2)

58 Branch
defect

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: sadikyalcin17, Unassigned)

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:58.0) Gecko/20100101 Firefox/58.0 Build ID: 20180206200532 Steps to reproduce: 1. Create a simple index.html 2. Create an element and set an inline css background image on it. 3. Create a IIFE getting the background via jQuery / vanilla JS 4. Load the index.html with an iframe 5. The background is undefined. 6. If you set a timeout, it might work. 7. If you view the page directly without loading it in an iframe, it returns the property. Example; <body> <div class="container" style="background-image: url('some-image.jpg')"> </div> <script type="text/javascript"> (function ($) { var bg = $('.container').css('background-image'); console.log(bg); // undefined setTimeout(function(){ var bg = $('.container').css('background-image'); console.log(bg); // url('some-image.jpg'); }, 1000); }(jQuery)); </script> </body> Actual results: bg variable returns undefined Expected results: bg variable should return the background-image property set.
Just like the point out that the above script works in all browsers including IE8, IE9, IE10, IE11, Chrome, Safari, Opera but not in FF58.
Component: DOM → CSS Parsing and Computation
Priority: -- → P2

Hey! I tried reproducing the bug but using the above example I was getting an error. There was a reference error where jQuery was not defined. Am I missing something? Some help would be great here.
Thank you.

We have similar problem at https://haberton.com but after sometime the error is gone probably our theme corrected it...

Severity: normal → S3

Calling WORKSFORME per comment 6.

(If this still reproduces, please let us know and ideally share a link or a live testcase that reproduces the issue. Thanks!)

Status: UNCONFIRMED → RESOLVED
Closed: 9 months ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.