Apply CSS Style to the parent page based on condition in an IFrame content.

I was given asn assignment to change theb back ground image of the parent page for a pop up window which as being opened using JQuery color box pluging.
The pop up page was being opened in an iFrame (html tag).
In Iframe we had a div with the Id and also we had the a Div with same name on parent page which was being added when pop up was comping up on the screen.
We needed to add background image for the div on parent page

We created a function to apply the CSS class which was having background image in it.

function SetBackGroundClass(classToSet) {
var overlay = $('div#cboxOverlay');
overlay.attr('class', classToSet);
$('#cboxOverlay', window.parent.document).addClass(classToSet);


This line adds css class to the parent page div

('#cboxOverlay', window.parent.document).addClass(classToSet);

This worked for us

Tags: ,

Comments are closed.