Grady D
Grady D

Reputation: 2019

Hide class if they have parent class

SharePoint 2013 uses iframes for the popups which causes issues when using a modified masterpage. The iframe has a class of .ms-dlgFrame and the element I am trying to hide is .navbar. I have tried using CSS with,

.ms-dlgFrame .navbar {
  display: none;
}

but it did not work. Using javascipt I am able to tell if the iframe class exists but when I try to hide the navbar it hides the navbar on the main page instead of the popup. The javascript I am using is,

if (document.getElementsByClassName('ms-dlgFrame').length) {
    document.getElementsByClassName('navbar')[0].style.Display='none';
}

How can I hide the navbar on the popup but not the main page?

enter image description here

Upvotes: 0

Views: 211

Answers (1)

Diodeus - James MacFarlane
Diodeus - James MacFarlane

Reputation: 114367

The iframe is a separate document, so the iframe content cannot be treated as a child element, as far as CSS goes. You need to address the iframe content directly.

This answer talks about how to do this. Just give your iframe an ID so the jQuery selector will work.

$("#iFrame").contents().find("#someDiv").removeClass("hidden");

Upvotes: 1

Related Questions