How to check if page opened in iframe


To check if page opened in iframe you can compare window.self and window.top Check the function below.

Source Code:

 <script>
	function is_in_iframe() {
		try {
			return window.self !== window.top;
		} catch (e) {
			return true;
		}
	}
</script>

Free - Download it right now!


Tested

Include all files

Demo Download

Buy us coffee

Compatible Browsers

Chrome, Firefox, Safari, Opera, IE9+, Edge

Technologies Used

HTML 5, JS, jQuery

Reviews and Comments