The content within the iframe is not displayed

I've set up a dropdown menu with separate iframes for each option. Here's the code I used:

$(function(){
  $('#klanten-lijst').on('change',function(){
    $('#klanten div').hide();
    $('.klant-'+this.value).show();
  });
});
.styled-select {
   background: url(http://i62.tinypic.com/15xvbd5.png) no-repeat 96% 0;
   height: 45px;
   overflow: hidden;
   width: 500px;
}

.styled-select select {
   background: transparent;
   border: none;
   font-size: 16px;
   height: 45px;
   padding: 5px; /* If you add too much padding here, the options won't show in IE */
   width: 520px;
}

...
<div>
<h2 style="margin: 0 0 20px">Clients</h2>
<div class="styled-select slate" style="position:fixed;margin-left:20px;">
  <select name="clients" id="klanten-list">
    ... (list of clients)
  </select>
  
<div id="klanten">
... (iframes for each client with links)
</div>

<script src="../scripts/client-reveal.js"></script>

</div>
</div>

I'm having trouble getting it to work and it's been frustrating me for some time now.

What's interesting is that when I manually change "hidden" to "show" using the browser console (F12), the frame appears on hover, but not its content. So I'm lost as to what might be causing the issue!

Any help would be appreciated, Roel

Answer №1

Instead of using the hidden attribute, consider removing it altogether. The JQuery .show() function adjusts the CSS display property to either block or inline-block based on the element used. To achieve the desired effect, you can either eliminate the hidden attribute with jQuery, or avoid using it entirely and apply display:none to all elements in the CSS so they are hidden until selected. Then, upon selection, utilize jquery.show()

For further information:

$(function() {
  $('#klanten-lijst').on('change', function() {
    $('#klanten div').hide();
    $('.klant-' + this.value).show();
  });
});
.styled-select {
  background: url(http://i62.tinypic.com/15xvbd5.png) no-repeat 96% 0;
  height: 45px;
  overflow: hidden;
  width: 500px;
}

.styled-select select {
  background: transparent;
  border: none;
  font-size: 16px;
  height: 45px;
  padding: 5px;
  /* If you add too much padding here, the options won't show in IE */
  width: 520px;
}

.styled-select.slate {
  background: url(http://i62.tinypic.com/2e3ybe1.jpg) no-repeat right center;
  height: 45px;
  width: 500px;
}

.styled-select.slate select {
  border: 1px solid #ccc;
  font-size: 16px;
  height: 45px;
  width: 520px;
}

#klanten {
  margin-top: 50px;
}

#klanten div {
  display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
  <h2 style="margin: 0 0 0px 20px">Klanten</h2>
  <div class="styled-select slate" style="position:fixed;margin-left:20px;">
    <select name="klanten" id="klanten-lijst">
    <option>Klanten</option>
<option value="1">7LAB LLP</option>
...
...
...
  (continues with more HTML code)

Answer №2

If you forget to include the jQuery library in your HTML, then using '$' won't work as expected.

$(function(){
  $('#klanten-lijst').on('change',function(){
    //$('#klanten div').hide();
    //$('.klant-'+this.value).show();
  });
});
.styled-select {
   background: url(http://example.com/image.png) no-repeat 96% 0;
   height: 45px;
   overflow: hidden;
   width: 500px;
}

.styled-select select {
   background: transparent;
   border: none;
   font-size: 16px;
   height: 45px;
   padding: 5px; /* If you add too much padding here, the options won't show in IE */
   width: 520px;
}

.styled-select.slate {
   background: url(http://example.com/anotherimage.jpg) no-repeat right center;
   height: 45px;
   width: 500px;
}

.styled-select.slate select {
   border: 1px solid #ccc;
   font-size: 16px;
   height: 45px;
   width: 520px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<div>
<h2 style="margin: 0 0 0px 20px">Klanten</h2>
<div class="styled-select slate" style="position:fixed;margin-left:20px;">
  <select name="klanten" id="klanten-lijst">
    <option>Klanten<option>
<option value="1">7LAB LLP</option>
<option value="2">A.Tuin Den Helder B.V.</option>
<option id="option3" value="3">Ace Accounting</option>
<option id="option4" value="4">Administratiekantoor A.C. Koenen</option>
<option id="option5" value="5">Advocatenkantoor Roos</option>
<option id="option6" value="6">Afix</option>
<option id="option7" value="7">Agratechniek</option>
<option id="option8" value="8">Anne van Dalen</option>
<option id="option9" value="9">App-vise</option>
<option id="option10" value="10">Arlette Hazevoet</option>
<option id="option11" value="11">Asko Schoonmaak- en Bedrijfsdiensten B.V.</option>
<option id="option12" value="12">ATAL B.V.</option>
<option id="option13" value="13">Australian Backpackers B.V.</option>
<option id="option14" value="14">Blommestein Gevelonderhoud</option>
<option id="option15" value="15">Blooming bedrijvengroep B.V.</option>
<option id="option16" value="16">Borst Bedden B.V.</option>
<option id="option17" value="17">Bouwbedrijf J. Nat. & Zn. B.V.</option>
<option id="option18" value="18">BouwBoxr B.V.</option>
<option id="option19" value="19">Broersma & De Boer Bouwadviesgroep B.V.</option>
<option id="option20" value="20">Bruin Assurantiën</option>
<option id="option21" value="21">Bureau Gras</option>
<option id="option22" value="22">Bureau4 V.O.F. </option>
<option id="option23" value="23">Business Center Bonne Chance B.V.</option>
<option id="option24" value="24">C.B.M. Poland</option>
<option id="option25" value="25">CaseWare Nederland B.V.</option>
<option id="option26" value="26">ColorCrew</option>
<option value="27">Coos</option>
<option value="28">Coperatieve Dienstverlening Heerhugowaard U.A.</option>
<option value="29"></option>
<option value="30"></option>
<option value="31"></option>
<option value="32"></option>
<option value="33"></option>
  </select>

<div id="klanten">
<div class="klant-1" hidden>
<iframe src="../klanten/7LAB LLP.html" style="height:410px;width:1880px;"></iframe>
</div>
<div class="klant-2" hidden>
<iframe src="../pages/home.html" style="height:410px;width:1880px;"></iframe>
</div>
</div>;

<script src="../scripts/customer-reveal.js"></script>

</div>
</div>

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

Leveraging server-sent events (SSE) for real-time updates on a web client using JavaScript

I have been experimenting with server-side events (SSE) in JavaScript and Node.JS to send updates to a web client. To simplify things, I created a function that generates the current time every second: setTimeout(function time() { sendEvent('time&a ...

A simple guide on accessing a local PDF file and returning it as the response for an ExpressJS application

In my ExpressJS application, I have a method for generating a PDF file and sending it to the client. However, there are cases where I need to retrieve an existing local PDF file and return it as the response. I'm unsure how to handle this scenario. ...

Jquery function for determining height across multiple browsers

I am currently facing an issue with setting the height of table cells in my project. While everything works smoothly on most browsers, Firefox seems to add borders to the overall height which is causing inconsistency across different browsers. If anyone k ...

Pug Template Not Displaying Emojis or Special Characters in Sendgrid Email Subject Line

There seems to be an issue with rendering emojis or special characters in the subject header of the pug file, although they work perfectly in the body. I have compiled both the body and subject header separately using pug. const compileHtmlFunction = pug.c ...

Acquiring the underlying code of websites within the local network

In the tool I am creating, it takes a URL as a parameter and retrieves the source code from that URL for analysis. The tool will be hosted on our domain, with the capability of analyzing web pages of sites within our internal network domain. Here is the Jq ...

Using Regex in Javascript to locate unfinished items that start and finish with brackets

Can anyone assist me in utilizing regex to identify any incomplete items that start with {{. I have attempted to search for instances in the string that begin with {{ and are followed by letters (a-Z) but do not end with }}. However, my attempts always re ...

Issue with using puppeteer for testing applications

Having an issue as a beginner in JavaScript, I'm struggling to solve this error. I am fetching data from a website using puppeteer and trying to verify if it's the correct one: const puppeteer = require('puppeteer'); (async () => { ...

Incorporate various style components to enhance the appearance of an item in ExtJS

I'm attempting to add ellipsis to an item created by ExtJS. My goal is to only modify this item without adding any additional CSS files. After researching, I discovered there is a "style" parameter that accepts CSS styles and attempted the following: ...

I am attempting to display the Δ symbol on my website, however, it is not appearing on the webpage

In my attempt to display my company logo on the website, I encountered an issue where the Δ symbol is not appearing correctly in the browser. strong class="footer-logo">KyΔnsys</strong To address this problem, I have implemented unicode charset=" ...

The Kenburn zoom image effect fails to function

I want to implement a zoom effect on an image using the Ken Burns effect when it is clicked. However, the code I have written does not seem to be working as expected. Here is the code snippet: $(document).ready(function () { $('.kenburns').on( ...

Experience a captivating Angular slideshow carousel that resets when you click on a dot button, all powered by the magical capabilities of

Check out this Stackblitz Link for a working sample. I have developed an angular carousel slider component using rxjs. Each slide changes after 5 seconds and everything is working smoothly. However, I am facing an issue where clicking on a particular dot ...

jquery: centralizing progressbar growth on the page

Working with Bootstrap progress bars is a regular task for me, and I have included a small example below. var $progress = $('.progress'); var $progressBar = $('.progress-bar'); var $alert = $('.alert'); setTimeout(function() ...

Tips for solving the "jQuery needs a window with a document" error when using import statements

I'm encountering the "jQuery requires a window with a document" error, and it appears that I require guidance similar to this solution: Error: jQuery requires a window with a document My quest is to find the precise syntax for addressing this using i ...

There seems to be an issue with the pseudo-elements :before and :after

I have been attempting to apply a double border to my table using the "border" property for one, and :before and :after for the second. However, I am facing an issue as it is not working properly. I am relatively new to CSS and HTML and have tried my bes ...

Unable to utilize a third setState function due to the error message indicating an excessive number of re-renders

My current challenge involves setting an initial state for my Hook. I have a clickable element that changes the state between Decreasing and Increasing upon click, and this part is functioning properly. However, I encounter an issue when attempting to defi ...

Is there a more efficient method for handling this JSON dataset?

After delving into Sitepoint's "Novice to Ninja" and starting to explore jQuery, I can't help but question if there is a more efficient way to write the code I've put together. The resounding answer appears to be "yes." All these cumbersome ...

What could be the reason for this JavaScript malfunctioning in both Chrome and Safari browsers?

Why is it that the javascript works fine in Firefox for the gallery on the page below, but doesn't seem to be functioning properly in Chrome and Safari? In Chrome, the big image isn't displaying but the thumbnails are, and in Safari nothing show ...

Dispatching identification to controller after submission

I am encountering an issue with a page that contains the following code: <div class="col-sm-2 displaybutton"> <div data-point-to="displaysHeader"> @using (Html.BeginForm("Administration", "Home", FormMethod.Post)) ...

The issue of CSS and PHP header include file not adjusting to device size and exceeding the full width of the screen

This included code is a snippet from a header file for a website. <head> <link rel="shortcut icon" href="favicon.ico"> <meta charset="utf-8" /> <title>Test Site | Foo The Bar </title> <link rel="stylesheet" href="csss_stan ...

What is the process for triggering data-dismiss after the href has been activated?

Could someone help me with this issue? <a class='btn btn-danger' href='page.html'>Delete</a> I am trying to activate the "data-dismiss" attribute after the "href" is activated. My initial attempt was using this code: < ...