Andrew
Andrew

Reputation: 3663

How to prevent Iframe tags from showing?

It has come to my attention that if you turn off Javascript, on Google Chrome(at least), the text <iframe> and its attributes are visible when Javascript is turned off and leave an odd appearance on the page.

You can test this on sites that use it. For example. turn JS off to see

Is this a bug? Is it considered a type of script, and should it be wrapped with "noscript"?

I'm sure companies that use iframes are unaware, I've noticed it on some Google pages too, there must be someway to get around it.

Upvotes: 0

Views: 36

Answers (1)

mohamed-ibrahim
mohamed-ibrahim

Reputation: 11137

i'm working with iframes but i'm not aware about this problem, but here is a hint if it helps.

You can start the page with iframe hidden:

<iframe style="display:none;"></iframe>

and once page load you can show them, then if javascript is enabled this line will run and will show them otherwise will kept hidden:

$("iframe").show();    //jQuery
document.getElementsByTagName('iframe').style.display = 'block'; //Pure Javascript 

Upvotes: 1

Related Questions