I have a Widget that I created and I am embedding it on other websites using an iFrame. What I want to do is make sure no one can view the source and copy the iFrame code and put it on their own website.
I can store the URL that it should be allowed on in the database. I've seen it done before, one site had a long encrypted code and if it didn't match with the domain then it said Access Denied..
Does anyone know how I can do this?
Thanks!
The X-Frame-Options response headerDENY : The page cannot be displayed in a frame, regardless of the site attempting to do so. SAMEORIGIN : The page can only be displayed in a frame on the same origin as the page itself. ALLOW-FROM uri : The page can only be displayed in a frame on the specified origin.
Select the Share or embed map option. Select the Embed map option, which will give you some <iframe> code — copy this. Insert it into the Input box below, and see what the result is in the Output.
The iframe element is supported by all modern desktop and mobile browsers. However, some browsers don't yet respond consistently to the three new HTML5 attributes for this element.
No you can't do this. The best thing you can do is the following:
if (window.top.location.host != "hostname") {
document.body.innerHTML = "Access Denied";
}
Add the above to your JavaScript and then use a JavaSript obfuscator
You cannot prevent people from looking at your HTML, but there are some headers can allow you to specify what sites can embed your iframe. Take a look at the X-Frame-Options
header and the frame-ancestors
directive of Content-Security-Policy
. Browsers that respect it will refuse to load the iframe when embedded into someone else's site.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With