Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting if this is an iframe load or direct

I am looking to only show a form if it is pulled on a page within an iframe. How do I do that? Is there a server side solution?

like image 821
Laura Avatar asked Dec 20 '10 23:12

Laura


1 Answers

If you are using JQuery... (installation instructions here: http://jquery.com/ )

$(document).ready(function(){ 
    if( window == window.top) { $('form#myform').hide(); }
});

Which just hides the form with id "myform" if the window is not the topmost window.

like image 80
stef Avatar answered Oct 05 '22 23:10

stef