How to hide iframe src?

Status
Not open for further replies.
8 comments
I'm curious why you would want to hide an IFRAME in the first place.

I can only think of a couple of reasons..

1. You have some sort of hit counter using an IFRAME which you should not be using. There's plenty of other ways to do this.

2. You're doing something illegal.

3. You're embedding music onto a site which again, there's better ways of doing.

Anyway,

Add a class or id to your IFRAME and do a display: none;
 
try this methode
stackoverflow.com/questions/24130231/i-want-to-make-an-iframe-hidden-by-default-and-to-be-shown-onclick-of-an-image
 
try something like - in html;
Code:
<script type="text/javascript" src="//js/embed.js"></script>

and inside embed.js

Code:
var id;
document.write("<iframe src ='"+id+"'><p>Your browser does not support iframes.</p>"+"</iframe>");


You could obfuscate even more if you needed but basically some variant of that^ should do, depending on your own requirements
 
Last edited:
I already did that but it still showing the source of the iframe if you go and inspect the element :/
Thanks

The inspector will show all elements, even those inserted dynamically with javascript. The basic HTML source view will not show javascript injected elements. There is no absolute method to hide an element.
 
<script type="text/javascript">
$(document).ready(function(e) {
$('iframe').attr('src','http://www.flickr.com/');
});
</script>

<body>
<iframe src="" />
</body>
 
Status
Not open for further replies.
Back
Top