• Skip to main content
  • Skip to primary sidebar
Making Different

Making Different

Create, Learn, Build or Fix

  • Tech
  • Business
  • Relationship
  • Health
  • Travel
You are here: Home / Web Development / JavaScript / How to Prevent Embedding Website Inside An Iframe?

How to Prevent Embedding Website Inside An Iframe?

May 10, 2021 by Nitin Maheta

How-to-Prevent-Embedding-Website-Inside-An-Iframe

In one of our previous posts, we have already discussed how to create an HTML iFrame in order to embed any document or a webpage to your website or blog. You can go check it out for more information.

Now, coming to an inline iFrame. An inline iFrame is primarily used to embed documents or web pages within the current document. If you’re familiar with basic HTML, it will be very easy for you to create an iFrame and get started right away.

However, if you’re someone who doesn’t know the basics of HTML, it doesn’t mean that you cannot accomplish this task with ease. You need to worry as we have already provided an iFrame Generator tool for you.

Our iFrame generator tool will help you to create an iFrame and customize it according to your requirements. The best part about our tool is that anyone can use it! You don’t need to learn about the HTML language to do a simple task.

Today, let’s talk about how you can prevent embedding your website or blog inside an iFrame. There are many websites on the internet that will embed your website content using iFrame tags for you, but you get to choose if you want to change that.

In case if you don’t want other websites to embed your content, you can prevent it by using a snippet code of JavaScript. This javascript code will help you to stop your page from being framed by someone else by redirecting the page embedding your page to your page only.

All you have to do is paste below javascript code before or
tag in your blog or website’s HTML code.

<script type="text/javascript">
function noiFrame() {
try {
if (window.top !== window.self) {
document.write = "";
window.top.location = window.self.location;
setTimeout(function() {
document.body.innerHTML = '';
}, 0);
window.self.onload = function() {
document.body.innerHTML = '';
};
}
} catch (err) {
}
}
noiFrame();
</script>

As you can see, the process to prevent the embedding of your website is quick and simple.



About Nitin Maheta

Nitin Maheta is editor in chief and webmaster of MakingDifferent Blog. You may reach him out on following social media:

Facebook | Twitter | Instagram

Primary Sidebar

Random Posts

office

How tone of voice affects communication

By Dinesh Goswami

chicken

Top Health Benefits of Eating Chicken

By Priya Batra

9 Useful Apps For People Who Are Deaf Or Have Hearing Loss

8 Useful Apps For People Who Are Deaf Or Have Hearing Loss

By Nitin Maheta

relaxing-music

Top 5 Most Relaxing Songs for Pleasurable Evening

By Nitin Maheta

DISABLE-CTRL-U-CTRL-C-AND-RIGHT-CLICK-ON-A-WEBPAGE-USING-JQUERY

How to Disable CTRL+U, CTRL+C and Right Click on a Webpage

By Nitin Maheta

All categories | About us | Contact us | Privacy policy | Disclaimer | Write for Us | Dictionary | Sitemap

The owner of this site is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to amazon.com.

© 2025 Making Different