1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How To Put an iFrame in JS?

Discussion in 'HTML & JavaScript' started by testoman, Feb 22, 2013.

  1. testoman

    testoman Registered Member

    Joined:
    Oct 11, 2008
    Messages:
    97
    Likes Received:
    11
    Occupation:
    manwhore
    Looking for a way to hide an iframe in a javascript file.
     
  2. trafficforweb

    trafficforweb Newbie

    Joined:
    Feb 22, 2013
    Messages:
    5
    Likes Received:
    1
    Code:
    var el = document.createElement("iframe");
        el.setAttribute('id', 'whatever');
        el.setAttribute('width', '1px');
        el.setAttribute('height', '1px');
        el.setAttribute('frameBorder', '0');
        document.body.appendChild(el);
        el.setAttribute('src', 'yourlink');
    Make sure you include the .js somewhere within the <body></body> tags.
     
    • Thanks Thanks x 1