Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide iframe src

I noticed that all the Facebook applications that running inside an iframe hiding their iframe SRC, instead of the real src there is a "javascript:""". How can i do that? I want that my iframe will hide the original src

thanks!

like image 316
udidu Avatar asked Feb 11 '12 23:02

udidu


People also ask

Can you hide an iframe?

The hidden attribute hides the <iframe> element. You can specify either 'hidden' (without value) or 'hidden="hidden"'. Both are valid. A hidden <iframe> is not visible, but maintains its position on the page.

How do I disable iframe?

Scroll down to the Miscellaneous category and click "Disable" under "Launching programs and files in an IFRAME." Click "OK" twice to save and activate your changes.


4 Answers

Facebook applications are loaded dynamically, which means the SRC is changed after the HTML is loaded. That is why you can only see javascript:;. The src is not hidden though, it is still there and can be obtained using javascript.

If you are using jQuery, you could use something like this:

<iframe src="javascript:;" id="myframe"></iframe>
<script>
$(document).ready(function() {
    $('#myframe').attr('src', 'http://facebook.com');
});
</script>

With this, the iframe will have javascript:; as src in the HTML, but will load facebook.com

like image 185
Tony Bogdanov Avatar answered Nov 06 '22 12:11

Tony Bogdanov


You are misunderstanding what you are seeing. Facebook is not "hiding" thi iframe src, it's just that the src is loaded via javascript. It's quite easy to see the iframe by using IE Developer tools (F12) or Firebug, or the native google chrome inspectors. There's nothing "hidden" about it, it just doesn't show up when you view source.

like image 42
Erik Funkenbusch Avatar answered Nov 06 '22 10:11

Erik Funkenbusch


Creat elem HTML:

<div id="htmlTest"></div>

JS code:

var blobMe= URL['createObjectURL'](new Blob([''], {type: 'text/html'}));
var elIframe = document['createElement']('iframe');
elIframe['setAttribute']('frameborder', '0');
elIframe['setAttribute']('width', '100%');
elIframe['setAttribute']('height', '500px');
elIframe['setAttribute']('allowfullscreen', 'true');
elIframe['setAttribute']('webkitallowfullscreen', 'true');
elIframe['setAttribute']('mozallowfullscreen', 'true');
elIframe['setAttribute']('src', blobMe);
var idOne= 'gepa_'+ Date.now();
elIframe['setAttribute']('id', idOne);
document.getElementById('htmlTest').appendChild(elIframe);
const iframeHere= 'https://www.youtube.com/embed/GdIEi4lIH_Q';
document['getElementById'](idOne)['contentWindow']['document'].write('<script type="text/javascript">location.href = "' + iframeHere + '";</script>')

Source: https://www.nodejsauto.com/2020/08/iframe-where-src-what-is-blob.html

like image 28
Diep Gepa Avatar answered Nov 06 '22 11:11

Diep Gepa


For me also want to hide src link in iframe. You can even refer to this url itself.

While inspect or View page source i can't able to find the src all i can find is only its id, Title & Name, is there anyway to achieve this.

like image 31
Mohan Raj Avatar answered Nov 06 '22 10:11

Mohan Raj