How can one prevent the buttons on another URL from opening by using Iframe?

Currently, I am utilizing an iframe to access another web service. The issue is that when users navigate to the targeted link, they can see the entire navigation menu. My goal is to restrict users from viewing the complete navigation menu.

The targeted URL contains five items, listed as follows:

  1. Overview
  2. Call Log
  3. Terrif
  4. Payment
  5. Logout

My aim is to limit users to only view the "Call Log" section.

Is there a way to achieve this? What steps should be taken to accomplish this task?

Answer №1

When your service is hosted on your own domain, you have the ability to access the frames DOM in this manner:

var myFrame = frames["myFrame"]

var cssLink = document.createElement("link") 
cssLink.href = "iframeStyles.css"; /* update this with the URL to a stylesheet specifically for the iframe */
cssLink.rel = "stylesheet"; 
cssLink.type = "text/css"; 
frames['myFrame'].document.body.appendChild(cssLink);

For further information, check out this question: How to add CSS class and control elements inside of the Iframe using javaScript?

If the iframe is loading content from a different domain, you won't be able to make modifications due to the same origin policy.

Answer №2

A few months back, I utilized this code but some tweaks may be needed:

<div id="IframeWrapper">
<div id="iframeBlocker">
</div>
<iframe id="mainframe" src="http://www.xyz.com/"></iframe>
</div>  

CSS:-

#IframeWrapper
{
    position: relative;
}

#iframeBlocker
{
    position: absolute;
    top: 0;
    left: 0;
    width: 700px;
    height: 450px;
}

#mainframe
{
    overflow: hidden;
    border-width: 0px;
}  

ANOTHER ALTERNATIVE AND A MORE EFFECTIVE ONE

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

Adjusting the height of a flexbox column to fit three rows within the space of two

Exploring the wonders of Flexbox and delving into its functionality. I have shared a Code Sandbox link showcasing my React /bootstrap code in progress... Currently, I am developing a clock component with two buttons for adjusting time (increase/decrease). ...

Is the :root selector truly devoid of value?

While I understand that :root can be used to select the html tag in an HTML file and the svg tag in an SVG file, I personally find it strange and not practical to apply the same styles to both HTML and SVG using :root. It seems like an unrealistic scenario ...

Updating the font style in MUI with React 18

I attempted to create a new theme in order to replace the default font family of MUI but unfortunately, it was not successful. This is what my theme component looks like: import { createTheme } from "@mui/material/styles"; const theme = createT ...

Combining CSS and HTML with IE10

With the release of Windows8 and IE10 as developer previews, I am curious about what features IE10 does not support that IE9/8 did, as well as what new features it now supports. Thank you for your assistance! ...

What is the best way to automatically assign a class attribute to all form widgets in Django?

Whenever I create a form using Django, I want the input tag to automatically include a specific CSS class (form-control). Currently, I have to manually add lines of code in my forms.py file for each field like this: class InsertItem(forms.ModelForm): ...

Organize divs based on their attributes

Using inspiration from this SO post, my goal is to group divs based on their "message-id" attribute. The idea is to wrap all divs with the same "message-id" in a div with the class name "group". <div class="message" message-id="1"> ...

The outcome of a Wordpress AJAX submission redirects to the admin-ajax.php file rather than appearing in the designated content

I've encountered an issue with the AJAX handler in WordPress. Here is the form that's causing trouble: form action="<?php echo site_url() ?>/wp-admin/admin-ajax.php" method="POST" id="filter" name="filter"> <input type="h ...

Update the button text dynamically when clicked without using an identifier or a class

If we take a look at my button in the following code: <input type="button" value="BLUE" name="button_blue" /> My goal is to have the value="BLUE" changed to value="RED" or any other desired value when the button is clicked. ...

Spotlight the flaw in the card's backbone using JS

What's the most effective method for emphasizing an error card view in backbone? Initially, I render 10 cards as UI where users input details in each card. Upon clicking submit, I validate all the details by parsing through collection->models. Curr ...

Sorting JSON data using JQuery Ajax

I've encountered an issue with sorting JSON data. Here is the JSON data I'm working with: [ { nom: "TERRES LATINES", numero: "0473343687", image: "http://s604712774.onlinehome.fr/bonapp/api/wp-content/uploads/2016/12 ...

Is there a flaw in how Firefox handles text-overflow and inline-block?

It seems that according to the text-overflow specification, the ellipsis effect only applies to inline elements: This property defines how content within an inline element is displayed when it overflows its container's boundaries in the inline dire ...

Modify the website's directory location in the IIS server to a different drive

Seeking guidance on how to relocate a website's path in IIS. The current website is set up on drive C:, but in light of space constraints, I am looking to migrate it to a different drive. Is it possible to achieve this without altering the inetpub pa ...

Is there a way to alter the styling of a React element without resorting to querySelector?

Just diving into React and I'm faced with a challenge - how to update the CSS of a class based on a condition. let customizeColumn = document.querySelector(".main-table-body"); !expandFilter ? customizeColumn.setAttribute("style", ...

Encountered problem parsing JSON with jQuery 1.9, though no issues were found when using eval

On the server side of my application, I have overridden java.Object.toString() to extract JSON without relying on any JSON library. The software versions in play are as follows: jQuery 1.9.0 and JDK 1.6.21 var jqxhr = $.ajax(url:"/getAvailableAddress.do" ...

The navbar links in Bootstrap 4 may be hidden, but the navbar brand still remains visible

I have implemented this code for my website's navbar, however, upon running it, I noticed that the navigation links are not visible. The navbar brand name "test" appears correctly, but the other links seem to be hidden. Does anyone have any insights o ...

The checkboxes seem to be malfunctioning following an ajax request

I've been attempting to utilize ajax to load data, but for some reason the checkboxes aren't functioning. Below is the HTML I'm trying to load via ajax: <div class="mt-checkbox-list" > <?php foreach($product_offerings as $row){ $c ...

Outlook's Dilemma with Background Images

I'm currently developing a new newsletter template, and I've encountered an issue with background images not displaying properly in Outlook. The code below illustrates the desired layout: <table style="width: 600px;" align="cent ...

Retrieving data via AJAX from an SD card

I am using the Atmel SAM4E-EK microcontroller as a server to host a webpage and send data over HTTP protocol. I am currently facing an issue with the download function while trying to download a file from my sd_card, which will not be larger than 512MB. s ...

Display or conceal a <div> segment based on the drop down selection made

A dropdown menu controls the visibility of certain div elements based on the selection made. While this functionality is working for one dropdown, it's not working for another even though the code is very similar. I've tried various solutions but ...

How can I control audio playback with just a click on an image on an HTML webpage?

I attempted to use a code from this website, but it doesn't seem to be working for me. I was hoping that someone here could lend a hand. The code I tried makes the song play when I click the gif image, but when I click it again, it just restarts. H ...