I've messed up my main question so I here I go again.
I have a mainrecord.html that uses iframe to display 2 html - top and lower. On the top html page I have a save button. This save button does some data work and then goes to a different html. The problem is the lower iframe is still there. Here is what I have in the mainrecord.html:
<iframe scrolling="no" noresize target="middle" src="<%=JustPath(oProp.ScriptPath)+[/top.html?id=]+tmpid"%> name="top" height="62%" class="auto-style1" style="width: 100%">You need a Frames Capable browser to view this content.</iframe>
<iframe scrolling="no" noresize target="middle" src="<%=JustPath(oProp.ScriptPath)+[/lower.html?id=]+tmpid"%> name="lower" style="width: 100%; height: 35%">You need a Frames Capable browser to view this content.</iframe>
<script type = "text/javascript" >
element = document.getElementById("lower");
</script>
In the top.html there is a save button that goes to a saverecord.html. I do some data work and then I do this:
<script type="text/javascript">
document.removeChild(element);
</script>
<% oResponse.Redirect(JUSTPATH(oProp.ScriptPath)+[/viewrecords.html])%>
It correctly displays viewrecords.html. However, the iframe containing lower.html is still there.
Any suggestions?
TIA.
You need to refer to a wrapping element in your JS to remove this Iframe.
<div class="frame2">
<iframe scrolling="no" noresize target="middle" src=""..." name="lower" style="width: 100%; height: 35%">You need a Frames Capable browser to view this content.</iframe>
</div>
JS
element = document.getElementById("frame2"); <-- this is the wrapper for your Iframe
document.removeChild(element);
Related
I am using iframe to embed an Excel file into a HTM page using the Microsoft OneDrive embed function, and it will display the excel file, but it doesn't embed it, it makes the entire page the excel file.
So it takes over the entire page, I lose the sidebar and toolbar of my site that has the navigation.
I tried containing it within a div and apply class styles to both the div and the iframe, which is what I used for my PDFs that I embed that work fine, but it still did not restrict the excel file to an embedded window.
This is what I am using for the excel iframe:
<body>
<iframe width="100%" height="100%" frameborder="0" scrolling="no" src="https://onedrive.live.com/embed?resid=7CDAFECF25AB92FC%21110&authkey=%21AGaGmMnPaiFZ0Ew&em=2">
</iframe>
</body>
And this is what I use for my PDF iframe:
<body>
<div class="container"><iframe class="responsive-iframe" src="PS-U-A150FUI.pdf"></iframe>
</div>
</body>
EDIT: Here are images to better show the issue, first image is a PDF correctly imbedded within the webpage.
Second is the excel doc that has overtaken the webpage.
PDF Embed
Excel Embed
Your code reads:
<iframe width="100%" height="100%" frameborder="0" scrolling="no" src="https://onedrive.live.com/embed?resid=7CDAFECF25AB92FC%21110&authkey=%21AGaGmMnPaiFZ0Ew&em=2">
</iframe>
You have used 100% width and 100% width in your HTML. So the iframe takes up the complete screen.
Take an example: you need the frame to be 500px wide and 700px long, then you could have used the width=“500px”
and the height=“700px” attributes in your iframe or used the following css:
iframe {
width: 500px;
height: 700px;
}
What basically I want to say is, that you should use smaller pixel-values/percentages for the iframe.
I have a web-page that allows the user to enter YouTube video URLs and display them in thumbnail previewers which do not auto-play them. When the user enters the URLs:
some may be valid and load,
some are not valid and don't load,
some, while valid URLs aren't embeds with URLs similar to
https://www.youtube.com/watch?v=NCZaq9pSBxQ and don't load, and
finally, while very rare, are valid, aren't embeds, but still load.
So, I don't want to prevent the user from entering any of these YouTube URLs, embed or not. Instead, I want to detect when the YouTube video doesn't load.
Here is some of the HTML 'code' that I'm using that shows one YouTube that doesn't load and one that does:
function update_ytplayer2( This ) {
// validate the textarea's value -- omitted
document.getElementById( 'ytplayer_2' ).src = This.value.trim();
}
.webvideourlPreview {
height: auto;
width: 75px;
max-height: 110px;
margin-right: 3px;
}
textarea {
width: 400px;
}
<iframe id="ytplayer_0" class="webvideourlPreview" scrolling="no"
src="https://www.youtube.com/watch?v=NCZaq9pSBxQ"
source="https://www.youtube.com/watch?v=NCZaq9pSBxQ"
video="true" youtube="true" style="display: block;"></iframe>
⁝<br />
<textarea onblur="update_ytplayer2( this );">https://www.youtube.com/embed/0376xWdwBBs</textarea><br />
⁝
<iframe id="ytplayer_2" class="webvideourlPreview" scrolling="no"
src="https://www.youtube.com/embed/0376xWdwBBs"
source="https://www.youtube.com/embed/0376xWdwBBs"
video="true" youtube="true" embed="true"
style="display: block;"></iframe>
Here is a codepen that shows the second iframe like it does in my web-page. which uses the same code and css styles as used above.
Here is what I see in the Chrome Browser's Inspect Element panel:
⁝
<!-- Non-Working YouTube Video -->
▼<iframe id="ytplayer_0" class="webvideourlPreview" scrolling="no"
src="https://www.youtube.com/watch?v=NCZaq9pSBxQ"
source="https://www.youtube.com/watch?v=NCZaq9pSBxQ"
video="true" youtube="true" style="">
</iframe>
⁝
<!-- Working YouTube Video -->
▼<iframe id="ytplayer_2" class="webvideourlPreview" scrolling="no"
src="https://www.youtube.com/embed/0376xWdwBBs"
source="https://www.youtube.com/embed/0376xWdwBBs"
video="true" youtube="true" embed="true" style="display: block;">
#document
<!DOCUMENT html>
▶<html lang="en" dir="ltr" data-cast-api-enabled="true"
wtx-context="AE89359A-CCF4-46DF-933F-36746B4B5815">
</html>
</iframe>
⁝
Both of the iframe tags are open, but I noticed that the non-working YouTube doesn't show anything between the open and close iframe tags, but the working YouTube does.
Is there some way that I can detect this in javaScript?
I saw that there was a .contentDocument property, but in Chrome this is always null, and there is a .contentWindow property, but both the non-working and working YouTube videos pretty much appear to show the same object/structure and so far I haven't found anything in the object that I can use to programmatically determine which video isn't working and which is.
I understand that there are two events that can be used, error and load, according to the information that I've found on these event because I'm not loading a file into the iframe, the events don't 'fire' whether the YouTube video loads or not.
I also saw somewhere in StackOverflow that the native size properties contain size of the small sad-face graphic, but I don't see how to get that information, especially since the .contentWindow doesn't appear, as far as I can tell, to these properties when I inspect these elements. However, I'd rather not rely only on the size of the image alone to determine the failure of the load.
Thanks
Actually YouTube doesn't allow 3rd parties to embed their site directly.
That is why using links like https://www.youtube.com/watch?v=NCZaq9pSBxQ or https://youtu.be/NCZaq9pSBxQ will raise Refused to display 'https://www.youtube.com/watch?v=NCZaq9pSBxQ' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'. warning in your console.
Fortunately Youtube offers "embed video" option, to allow us to embed videos. Using this feature I had written my code. Check out this snippet:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test</title>
<style type="text/css">
.webvideourlPreview {
height: auto;
width: 75px;
max-height: 110px;
margin-right: 3px;
}
textarea {
width: 400px;
}
</style>
<script type="text/javascript">
function update_ytplayer2( This ) {
//capture trimmed value
let val = This.value.trim();
let embed_src;
if(val.includes('watch?v='))
embed_src = This.value.replace("watch?v=", "embed/");
else if(val.includes('youtu.be'))
embed_src = 'https://www.youtube.com/embed/'
+ val.split('/').pop();
// validate the textarea's value -- omitted
document.getElementById( 'ytplayer_2' ).src = embed_src;
}
</script>
</head>
<body on>
<iframe id="ytplayer_0" class="webvideourlPreview" scrolling="no"
src="https://www.youtube.com/watch?v=NCZaq9pSBxQ"
source="https://www.youtube.com/watch?v=NCZaq9pSBxQ"
video="true" youtube="true" style="display: block;"></iframe>
⁝<br />
<textarea onblur="update_ytplayer2( this );">https://www.youtube.com/watch?v=NCZaq9pSBxQ</textarea><br />
⁝
<iframe id="ytplayer_2" class="webvideourlPreview"
style="display: block;"></iframe>
</body>
</html>
In the snippet, inside function update_ytplayer2 we using val variable to save trimmed value of our <textarea>. Next depending on the type of link, we may or may not altering it to get link in the form of https://www.youtube.com/embed/[unique_identifier] and save it into another variable embed_src.Finally, setting embed_src as our <iframe> source.
Function update_ytplayer2 called each time user generate blur effect on <textarea> by moving focus away from it which in turn updates the video shown in <iframe id="ytplayer_2">.
Note: I had removed the HTML5 non-standard attributes from the <iframe id="ytplayer_2">.
I have an iframe that opens a page with an ad.
<iframe frameborder=0 height=100% marginheight=0 marginwidth=0 scrolling=no seamless src="http://pad.ample.pw/ad1/ad1.php" style=margin:0;padding:0;overflow:hidden;border:0 width=100%></iframe>
However, when I open it on the iPhone. It's blank.
Is there something preventing iOS from displaying this frame?
Note:
If you open the url outside of an iframe it redirects elsewhere. In my case will redirect to a FB page.
The attributes in ur iframe element aren't into quotes.
For example, it should be
< iframe style="margin : 0px ; padding : 0px ">
and so on.
Since your syntax is wrong, the html wont render properly.
I'm currently using Jmeter webdriver for performance test on a web application. I'm trying to click on a button on the page, but this is under a few frames. The problem one of the frame, that changes name for every session. This is the HTML code:
<iframe frameborder="0" id="iframe3970-45593-1439460248299" tabindex="-1" src="https://grcrep.fiatitem.com/BOE/portal/1508131050/AnalyticalReporting/WebiView.do?bypassLatestInstance=true&cafWebSesInit=true&bttoken=MDAwREcwXFo2V25vZk00QTtoS1xiUko5Y2Y6T11qOzAEQ&bttoken=MDAwREcwXFo2V25vZk00QTtoS1xiUko5Y2Y6T11qOzAEQ&opendocTarget=infoviewOpenDocFrame&appKind=InfoView&service=%2FInfoView%2Fcommon%2FappService.do&loc=en&pvl=en_US&ctx=standalone&actId=3970&objIds=45593&containerId=45589&pref=maxOpageU%3D50%3BmaxOpageUt%3D200%3BmaxOpageC%3D10%3Btz%3DEurope%2FBerlin%3BmUnit%3Dinch%3BshowFilters%3Dtrue%3BsmtpFrom%3Dtrue%3BpromptForUnsavedData%3Dtrue%3B&tidtime=3970-45593-1439460248299" style="width: 1600px; height: 703px;"></iframe>
...
<iframe id="webiViewFrame" name="webiViewFrame" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" style="margin:0px;position:absolute;left:0px;top:0px;width:100%;height:100%" src="webiDHTML/dhtmllib/empty.html"></iframe>
...
<div id="IconImg_iconMenu_icon__dhtmlLib_268" class="imo" style="width:16px;height:16px;background-image:url('images/main/galleries/icon16x16gallery1b.png');background-position:0px -208px;margin-top:2px;cursor:pointer"></div>
I want to click on the button with id=IconImg_iconMenu_icon__dhtmlLib_268
that is under the iframe webiViewFrame and the iframe iframe3970-45593-1439460248299. This last frame changes name at every session. The only part that is fixed is iframe3970-. How can I locate this element. I've tried using regular expression WDS.browser.findElement(pkg.By.id("iframe3970-"+"([0-9]+?)")) but it doesn't work.
Try locate iframe with an id that starts with the text prefix:
WDS.browser.findElement(pkg.By.cssSelector("iframe[id^='iframe3970-']"))
I found answers about how to do this WITH php (example: load HTML\PHP pages into another Page's div).
However, I need to be able to do this in a CKEditor and I don't have the ability to include PHP code (or javascript or any other code).
Here's the existing iframe I wish to replace with divs (if possible):
<iframe src="http://www.example.com/page1/2/3.html" frameborder="0" height="400" scrolling="no" width="100%"></iframe>
I appreciate any ideas... Thanks
Why dont you try AJAX to load the content?
//Its a javascript code:
<script type="text/javascript">
$('#15').click(function()
{
$(".box").load('content8.html');
});
$('#16').click(function()
{
$(".box").load('edit.html');
});
</script>
// For Displaying the content, create a seperate DIV:
<div class="box effect8" >
"The Ajax content loaded inside this div"
</div>
Unfortunately, what you are trying to do is simply not possible. However. what you can do is apply styles to your iframe to make it work more like a div. An iframe is inline, and a div is block. You can make your iframe block so that it behaves like a div.
Without CSS:
<iframe style="display:block" src="http://www.example.com/page1/2/3.html" frameborder="0" height="400" scrolling="no" width="100%"></iframe>
With CSS:
iframe
{
display: block;
}