How to create an iframe on clicking a link?

前端 未结 4 1965
一个人的身影
一个人的身影 2021-01-17 06:35

I have a web page with several links inside a table. One of the links is inside a td tag . I want a way to invoke an iframe, which will be opened once the user clicks on the

4条回答
  •  不思量自难忘°
    2021-01-17 07:03

    Heres a very basic JavaScript function that can do it. Function parameters are the element in which you want the iFrame to be appended to and the location in which you want it to point.

    HTML

    Set the Iframe up
    

    JavaScript

    function setIframe(element,location){
        var theIframe = document.createElement("iframe");
        theIframe.src = location;
       element.appendChild(theIframe);
    }
    

提交回复
热议问题