Making modifications to the CSS within an embedded iframe webpage

Assigned with the task of implementing a specific method on a SharePoint 2013 site. Let's dive in.

Situation: - Within a page on a SharePoint 2013 site, there is a "content editor" web part that displays a page from the same domain/site collection. The code below (not authored by me) has been inserted into the content editor and successfully displays the page.

Challenge - My objective is to remove the global navigation from the page within the content editor, presumably done through an Iframe. Using F12 dev tools in IE11, I have identified the CSS class ms-dialog #globalNavBox and set its display to "none", achieving the desired look.

The only hurdle remaining is how to execute this action using some form of code on the embedded page itself.??

This is the current code used in the content editor to display the page for modification:

#mydiv{

width:1280px; height:1000px;
 overflow:hidden;
 ;
}

#myframe{
 ;
 top:-190px;
 left:-100px;
 width:1080px;
 height:1000px;

}
</style>
<div id="mydiv">
<iframe id="myframe" src="/gen/genInduction/Lists...blah scrolling="no"></iframe>&#160;</div>

As of now, I am unsure of how to include the code (if possible) to remove the css .ms-dialog #globalNavBox {display: none;} so that upon page display, the global navigation is eliminated.

I trust this explanation clarifies my situation, as it marks my first time seeking assistance on this platform. Despite extensive prior research, attempts to resolve this issue have been unsuccessful as the solution eludes me.

Answer №1

Insert the code below within your web page, placing it after the iframe.

<script>
document.getElementById("myframe").contentDocument.getElementById("globalNavBox").style.display="none";
</script>

Answer №2

It is my understanding that you will still have access to the content of the iframe as long as both elements are from the same domain, unless the iframe has been sandboxed (which is not the case in the provided example). Building upon JBiserkov's concise response, I would like to address some considerations regarding the loading process of an iframe. In certain scenarios, there might be a slight delay in the iframe loading, so it is advisable to anticipate this possibility. I found the following resources helpful in grasping the concept of iframes:

Iframes, Onload, and Document.domain

Iframe Tutorials

-Information about the iframe

var iFrame = document.getElementById('myframe'),

-Accessing the document object of the iframe

-The use of this shortened conditional expression is crucial for interacting with the contents within the iframe.

iDoc = iFrame.contentDocument ? iFrame.contentDocument : iFrame.contentWindow.document,

-Identifying the target element #globalNavBox

gNav = iDoc.getElementById('globalNavBox');

-Upon the iframe being fully loaded, altering the style of globalNavBox to "display" and setting it to "none"

iframe.onload = function () {
        gNav.style.display = 'none';
};

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Transferring information between a pair of PHP functions via AJAX communications

Currently, I am tackling the challenge of user verification on our website. The process involves prompting users to input their credentials, click on the "send confirmation" button, receiving a code through SMS or messenger, entering the code in a field, a ...

Attempting to navigate the world of AJAX and PHP

My experience with AJAX is limited, but I am currently working on a project that requires a form to submit data without refreshing the page. The goal is to display the result in a modal window instead. To achieve this functionality, I understand that imple ...

Storing multiple text box values into a single application variable in C# - A Comprehensive Guide

[code page="c#"] Hdnano.Value = Application["AccountNum"].ToString(); $(document).ready(function() { $("#ano").on("blur", function() { var accountNum = $('textarea#ano').val(); $("#Hdnano").val(folioNum); }); &l ...

Ways to apply styles to the final element containing a specific class within a nested list using CSS

Styling the final HTML element with a specific css class presents challenges due to certain constraints that must be considered. In the website I'm currently working on, the navigation menu consists of multiple nested lists. When an element is clicke ...

ValueError: Unable to perform slicing operation on this data

When attempting a query in nodejs, I encounter this error: [2017-08-19 19:06:55.946] [ERROR] error - TypeError: val.slice is not a function at escapeString (/var/www/Bot/node_modules/sqlstring/lib/SqlString.js:183:23) at Object.escape (/var/www/Bo ...

Creating an overlay effect when hovering over an image

Recently, I've been working on a gallery of photos that showcases different individuals. My goal is to have information about each person displayed when their respective photo is hovered over - including their name and role. .gallery { position: ...

Navigating through Dynamic URL Parameters with RouterLink in an Angular Application

Within my Angular 2 application, there exists a tab section where users can choose from a collection of separate yet contextually connected components. By clicking on one of these links, the corresponding component is loaded based on the routerLink definit ...

What is the best way to show the response data in an input text field within an HTML form?

I'm new to working with node.js and I've encountered an issue. I need to display the data of the currently logged in user in input fields. With the following code, I can access the data of the logged-in user and display it on the console: See O ...

Can you explain the purpose of the square brackets within the ".module("modulename", [...])" syntax used in AngularJS?

I recently came across a sample demonstrating routing in AngularJS. I am curious about the connection between the dependency 'ngRoute' and the module mainApp, as shown in the syntax var mainApp = angular.module("mainApp", ['ngRoute']);. ...

Encountering Routing Issues in Express.js Following Passport.js Authentication

My authentication setup with Passport.js is pretty straightforward. After the user successfully authenticates, I redirect them to /work like this. app.post('/login', passport.authenticate('local', { successRedirect: '/ ...

Finding a solution to the type issue of error handling in Route Handler with NextJS

I'm working on a route handler located at app/api/transactions/route.ts. Here's a snippet of the code: import { NextRequest, NextResponse } from "next/server"; import { AxiosError } from "axios"; import axios from "../axi ...

Steps for adding a view to an element

Can someone help me with the syntax needed to append my template within the div "#draggableContainers"? I feel like I'm overlooking something simple. <html xmlns="http://www.w3.org/1999/xhtml"> New Page Title <script src="https://ajax ...

The files being requested by jQuery Slimbox are not being retrieved properly

I am currently utilizing jQuery slimbox along with its Application Programming Interface (API). Below is the JavaScript code snippet that retrieves image paths through JSON and then triggers the slimbox using its API. $('#main-container').appen ...

Techniques for slowing down the propagation of events with jQuery

Is there a way to show a note after a user submits a form but before they leave the page? Here is an example of what I'm currently using: $('form').submit(function(event) { $('.note').show(); setTimeout(function() { ...

Increase the date by one day excluding weekends (Saturday and Sunday)

My current code is designed to add +1 day to the current date. var date = '30 Apr 2010'; var actual_date = new Date(date); var final_date = new Date(actual_date.getFullYear(), actual_date.getMonth(), actual_date.getDate()+1); Now, I am looking ...

Modifying pagination numbers with Reactjs: A step-by-step guide

I am currently working on Reactjs (nextjs) and I have successfully integrated the "Nextjs" framework. The pagination is working fine, but the buttons are displaying as "1,2,3,20" instead of "1,2...20" (showing all numbers without using "..."). How can I mo ...

I encountered an issue while trying to use jshint with a simple hello world script, receiving the error message: "line 0, col 0, Bad option: 'script'."

This is a basic introduction to my coding journey. function greet() { return 'Hello world'; } Here is the jshint setup I am using: { "browser": true, "browserify": true, "devel": true, "script" ...

Trigger a JavaScript/jQuery alert if the text input field contains a specific string

I am currently facing an issue with a text field (id=#CAT_Custom_244677) that gets populated by a JavaScript date picker. My goal is to display an alert message if the user selects a date that includes '2013' in the text field value. However, I h ...

``There is an issue with the onsubmit property that prevents the opening of

I have encountered an issue with my forms that has me stumped. Despite searching online for help, I can't seem to figure out why my implementation is not working as intended. The concept is straightforward. I've embedded a form within a JSP page ...

Is it recommended to utilize addEventListener?

Is it better to use the addEventListener method in these scenarios? <input id="input" type="file" onchange="fun()> or document.getElementById("input").addEventListener("change", function() { fun(); }); What are the advantages of using one over ...