Initiating an Iframe through Button Click: A Guide

For those who prefer using jQuery, it’s better to fully embrace it instead of mixing it with other tools. In case you require three buttons, there are two options available. The first option involves using HTML and JavaScript/JQuery, as demonstrated in the working example available at http://codepen.io/anon/pen/vxRxPm. Alternatively, the second option is to avoid using accordions since they are usually not a desirable user interface pattern and can be challenging for developers to work with.


Solution:

To obtain it, simply mention the name of the iframe within the link HTML generation code, as indicated by

target

.

To incorporate, simply insert the following

name

property into your iframe.


Subsequently, include a property identified as

target

.

document.getElementById('mylink').innerHTML = '' + link[intlinkIndex] + '';
function writeLink() {
    if (intlinkIndex >= link.length) {
      let btn = document.getElementById('btn');
      btn.style.display = 'none';
      mylink.style.display = 'none';
    }
    document.getElementById('mylink').innerHTML = '' + link[intlinkIndex] + '';
    document.getElementById('iframe').src = link[intlinkIndex];
    intlinkIndex++;
  }

Full source code












 

Frequently Asked Questions