How would I remove the border from an iframe embedded in my web app? An example of the iframe is:
<iframe src="myURL" width="300" height="300">Browser not compatible.</iframe>
I would like the transition from the content on my page to the contents of the iframe to be seamless, assuming the background colors are consistent. The target browser is IE6 only and unfortunately solutions for others will not help.
Add the frameBorder attribute (note the capital ‘B’).
So it would look like:
<iframe src="myURL" width="300" height="300" frameBorder="0">Browser not compatible.</iframe>
After going mad trying to remove the border in IE7, I found that the frameBorder attribute is case sensitive.
You have to set the frameBorder attribute with a capital B.
<iframe frameBorder="0"></iframe>
As per iframe documentation, frameBorder is deprecated and using the "border" CSS attribute is preferred:
<iframe src="test.html" style="width: 100%; height: 400px; border: 0"></iframe>
Note CSS border property does not achieve the desired results in IE6, 7 or 8.
In addition to adding the frameBorder attribute you might want to consider setting the scrolling attribute to "no" to prevent scrollbars from appearing.
<iframe src="myURL" width="300" height="300" frameBorder="0" scrolling="no">Browser not compatible. </iframe >
For browser specific issues also add frameborder="0" hspace="0" vspace="0" marginheight="0" marginwidth="0" according to Dreamweaver:
<iframe src="test.html" name="banner" width="300" marginwidth="0" height="300" marginheight="0" align="top" scrolling="No" frameborder="0" hspace="0" vspace="0">Browser not compatible. </iframe>
You can use style="border:0;" in your iframe code. That is the recommended way to remove border in HTML5.
Check out my html5 iframe generator tool to customize your iframe without editing code.
Use the HTML iframe frameborder Attribute
http://www.w3schools.com/tags/att_iframe_frameborder.asp
Note: use frameBorder (cap B) for IE, otherwise will not work. But, the iframe frameborder attribute is not supported in HTML5. So, Use CSS instead.
<iframe src="http://example.org" width="200" height="200" style="border:0">
you can also remove scrolling using scrolling attribute
http://www.w3schools.com/tags/att_iframe_scrolling.asp
<iframe src="http://example.org" width="200" height="200" scrolling="no" style="border:0">
Also you can use seamless attribute which is new in HTML5. The seamless attribute of the iframe tag is only supported in Opera, Chrome and Safari. When present, it specifies that the iframe should look like it is a part of the containing document (no borders or scrollbars). As of now, The seamless attribute of the tag is only supported in Opera, Chrome and Safari. But in near future it will be the standard solution and will be compatible with all browsers. http://www.w3schools.com/tags/att_iframe_seamless.asp
Style property can be used
For HTML5 if you want to remove the boder of your frame or anything you can use the style property. as given below
Code goes here
<iframe src="demo.htm" style="border:none;"></iframe>
I tried all of the above and if that doesn't work for you try the below CSS resolved the issue for me. Which just tells the browsers to not add any padding or margin.
* {
padding:0px;
margin:0px;
}
You can also do it with JavaScript this way. It will find any iframe elements and remove their borders in IE and other browsers (though you can just set a style of "border : none;" in non-IE browsers instead of using JavaScript). AND it will work even if used AFTER the iframe is generated and in place in the document (e.g. iframes that are added in plain HTML and not JavaScript)!
This appears to work because IE creates the border, not on the iframe element as you'd expect, but on the CONTENT of the iframe--after the iframe is created in the BOM. ($#&*##!!! IE!!!)
Note: The IE part will only work (of course) if the parent window and iframe are from the SAME origin (same domain, port, protocol etc.). Otherwise the script will get "access denied" errors in the IE error console. If that happens, your only option is to set it before it is generated, as others have noted, or use the non-standard frameBorder="0" attribute. (or just let IE look fugly--my current favorite option ;) )
Took me MANY hours of working to the point of despair to figure this out...
Enjoy. :)
// =========================================================================
// Remove borders on iFrames
var iFrameElements = window.document.getElementsByTagName("iframe");
for (var i = 0; i < iFrameElements.length; i++)
{
iFrameElements[i].frameBorder="0"; // For other browsers.
iFrameElements[i].setAttribute("frameBorder", "0"); // For other browsers (just a backup for the above).
iFrameElements[i].contentWindow.document.body.style.border="none"; // For IE.
}
Add the frameBorder attribute (Capital ‘B’).
<iframe src="myURL" width="300" height="300" frameBorder="0">Browser not compatible. </iframe>
In your stylesheet add
{
padding:0px;
margin:0px;
border: 0px
}
This is also a viable option.
Either add the frameBorder attribute, or use style with border-width 0px;, or set border style equal to none.
use any one from below 3:
<iframe src="myURL" width="300" height="300" style="border-width:0px;">Browser not compatible.</iframe>
<iframe src="myURL" width="300" height="300" frameborder="0">Browser not compatible.</iframe>
<iframe src="myURL" width="300" height="300" style="border:none;">Browser not compatible.</iframe>
If the doctype of the page you are placing the iframe on is HTML5 then you can use the seamless attribute like so:
<iframe src="..." seamless="seamless"></iframe>
Mozilla docs on the seamless attribute
If you are using the iFrame to fit the width and height of the entire screen, which I am assuming you are not based on the 300x300 size, you must also set the body margins to "0" like this:
<body style="margin:0px;">
<iframe src="mywebsite" frameborder="0" style="border: 0px solid white;">HTML iFrame is not compatible with your browser</iframe>
This code should work in both HTML 4 and 5.
also set border="0px "
<iframe src="yoururl" width="100%" height="100%" frameBorder="0"></iframe>
Try
<iframe src="url" style="border:none;"></iframe>
This will remove the border of your frame.
Use this
style="border:none;
Example:
<iframe src="your.html" style="border:none;"></iframe>
To remove border you can use CSS border property to none.
<iframe src="myURL" width="300" height="300" style="border: none">Browser not compatible.</iframe>
1.Via Inline Style set border:0
<iframe src="display_file.html" style="height: 400px; width:
100%;border: 0;">HTML iFrame is not compatible with your browser
</iframe>
2. Via Tag Attribute frameBorder Set 0
<iframe src="display_file.html" width="300" height="300" frameborder="0">Browser not compatible.</iframe>
3. if We have multiple I Frame We can give class and Put css in internal or externally.
HTML:
<iframe src="display_file.html" class="no_border_iframe">
HTML iFrame is not compatible with your browser
</iframe>
CSS:
<style>
.no_border_iframe{
border: 0; /* or border:none; */
}
</style>
Its simple just add attribute in iframe tag frameborder = 0
<iframe src="" width="200" height="200" frameborder="0"></iframe>
for me, adding worked perfectly
.iframe{
box-shadow: none !important;
}
this solution is particularly for a shopify theme I am editing. The shopify theme uses iframes in different ways throughout the whole theme and one of them glitched. I had to go into the css manually and overide the css attribute.
I had an issue with bottom white border and i could not fix it with border, margin & padding rules ... So add display:block; because iframe is an inline element.
This takes whitespace in your HTML into account.
iframe src="XXXXXXXXXXXXXXX"
marginwidth="0" marginheight="0" width="xxx" height="xxx"
Works with Firefox ;)
<iframe src="URL" frameborder="0" width="100%" height="200">
<p>Your browser does not support iframes.</p>
</iframe>
<iframe frameborder="1|0">
(OR)
<iframe src="URL" width="100%" height="300" style="border: none">Your browser
does not support iframes.</iframe>
The <iframe> frameborder attribute is not supported in HTML5. Use CSS
instead.
Related
In my Angular app, I have included the following snippet in an html template:
<embed src="../assets/AOK_T2DM.pdf" style="width: 100%;height: 500px" type="application/pdf">
It appears as follows:
When I click open, the pdf file is downloaded.
How can I simply display the content instead of downloading it?
<iframe src="https://docs.google.com/viewer?url=https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf&embedded=true" frameborder="0" height="600" width="100%"></iframe>
Use Below Code
<iframe src="https://docs.google.com/viewer?url=File_URL&embedded=true" frameborder="0" height="1100px" width="100%"></iframe>
Set height as per your need or give the height as 100% and set the height for the parent div.
Check and update if it works.
I want to solve the problem in Google Map when I do z-index: -1 Do not activate the map but the div is above the map as I want ... I want to activate the map with the div remains above the map
<div id="map" style="z-index: -1;"></div>
<div id="filter-div-for-sale-mobile" style="transform-origin: left 78.5px;top: 39px;left: -273.61px;width:360.5px;" class="zsg-popover_arrow-up zsg-popover-adjustable popover-thick-top popover-no-close popover-visible filter-button-popover listing-type-popover">
I would recommend using the iframe option provided by Google as it is much more controllable in regards to the CSS styling perspective of making it responsive on a page.
Sample of what I mean. (the width and height for the iframe attribute aren't required)
<iframe width="600" height="450" frameborder="0" style="border:0"
src="https://www.google.com/maps/embed/v1/view?zoom=10¢er=51.5074%2C-0.1278&key=..." allowfullscreen></iframe>
It could be helpful to include the position of your element (fixed,relative or absolute ) etc.
Also what browser are you using?
I have tried the following code:
<iframe controls="0" autoplay="0" class="embed-responsive-item" src="videos/first_video.mp4"></iframe>
I have tried many things but not getting any solution. I want to disable the autoplay on the video and don't want to use <video> tag so its possible without <video> tag?
I think this is what you want.
function a() {
var iframe = document.getElementById("iframe");
iframe.src = "video.mp4"
}
<iframe src="imagename" height="200" width="300" id="iframe"></iframe>
<button onclick="a()">Play</button>
iframe does not support this by default. Why do you not want to use video tag? The only thing I can think of to make it look like an iframe without autoplay is with help of javascript.
First set the iframe src to empty or leave the src out.
Set a picture as iframe background to make it look like the video.
<iframe style="background-image:url(picture.png)" id="frame" controls="0" class="embed-responsive-item" src=""></iframe>
Then create an onclick event for that iframe and change the iframe src
function loadVideo() {
var frame = document.getElementById("frame");
frame.src = "video.mp4";
}
I would consider using video tag or a plugin that works on every browser.
According to this article the syntax should go like this:
<iframe src="https://cross-origin.com/myvideo.html" allow="autoplay; fullscreen"></iframe>
<iframe src="https://cross-origin.com/myvideo.html" allow="fullscreen"></iframe>
<iframe src="https://cross-origin.com/myvideo.html" allow=""></iframe>
This is fairly new (at least to me) and I don't see explicit directions as to how autoplay is shut off. Try either the second or third example. This is part of the new feature policy called iframe delegation which will go into full effect on april 2018. I will add onto this answer if I find more concrete info.
I have a we page that is included inside an iframe on another domain. The issue is that the iframe is always loaded with vertical scrollbar. I checked the markup and here is how they include the iFrame:
<iframe class="plugin-frame js-plugin-frame" frameborder="0" marginheight="0" marginwidth="0" width="100%" height="auto" sandbox="allow-scripts allow-forms allow-same-origin allow-popups allow-top-navigation" src="https://mydomain/mypage.html"></iframe>
If I change the above to:
<iframe class="plugin-frame js-plugin-frame" frameborder="0" marginheight="0" marginwidth="0" width="100%" min-height="600px" sandbox="allow-scripts allow-forms allow-same-origin allow-popups allow-top-navigation" src="https://mydomain/mypage.html"></iframe>
it works.
Is there anything that I can do on my page to make it work. I need to get rid of the vertical scrollbar and have no control over the third party markup. Is there anything needed in the markup of my iframe to fix this?
If you don't want to have the scrollbar, but do want to allow scrolling, you can add the following CSS (only works in WebKit):
::-webkit-scrollbar {display: none}
If you don't want to have the scrollbar and you don't want scrolling then you can do this:
body, html { overflow-y: hidden }
Since I assume you want to only apply these styles if your page is iframed, use this JavaScript to get the job done:
if (top != self) {
var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = '::-webkit-scrollbar {display: none}';
document.head.appendChild(style);
}
<iframe id="sample_test" src="http://localhost:3000/tests/384" seamless="seamless" width="100%" height="1150px" scrolling="no">
</iframe>
This frame renders also #current_user_bar, which this way is displayed twice: from layout, and from frame.
How can I make it invisible in frame(but visible else content of the frame)?
Try this: $("#sample_test").contents().find("#current_user_bar").hide();