Position an iframe's div relatively to the window - javascript

I'm using http://notifyjs.com and I think it's working great.
However I have this issue when applying it to my case.
I want to display a notification using notify.js in the bottom right corner. And this notification should not disappear until users click on it (just to make sure they don't miss it)
When I run my web locally, everything is working fine. The notification is displayed in bottom right corner of the window, and it stays there regardless of scrolling.
$.notify('HelloWorld',
{
className: 'success',
autoHide: false,
clickToHide: true,
position: "bottom right"
}
);
However, when I deploy it to the UAT server in which our web application is only an iframe, the notification is displayed in the corner, but it's in the corner of the iframe, so it might go off the users' screen when they scroll, or they can't see it because it appears when they are not the bottom of iframe.
Please help to advise how I can position an iframe's div relatively to the window is possible. Thanks very much in advance.
==================================================
The html looks something like this:
<html>
<head>...</head>
<body>
<div id="container">
...
<div id="main-content">
<div id="iframe-container">
<iframe id="Main" name="Main" frameborder="0" scrolling="no">
<html>
<body>
...
<div class="notifyis-corner" style="right: 0px; bottom: 0px;">...</div>
</body>
</html>
</iframe>
</div>
</div>
</div>
</body>
</html>
I can see the css for notifyjs-corner as below:
.notifyjs-corner {
position: fixed;
margin: 5px;
z-index: 1050;
}

Related

Image Appear upon Scrolling down Page | Sharepoint Online Embed

I have embeded the following code onto my sharepoint online site. The image appears in the bottom right hand corner and once clicked it takes me to the top of the page, as coded; however the Jquery javascript code doesn't appear to work... The image just stays visible regardless of how many pixels are scrolled.
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.js"><\script>
<script>
$(window).scroll(function() {
if ($(this).scrollTop()>100) {
$('#toTop').fadeIn();
} else {
$('#toTop').fadeOut();
}
});
</script>
<div id="toTop">
<a style="position: fixed; bottom:20px;left:5px;" href="#ctl00_onetidHeadbnnr2" title="Back to Top"><img style="border: none; height: 37.5px; width:50.5px" src="backtotop-1.png" ></a>
</div>
The above code encompasses both suggested solutions and still doesn't appear to work! The image is visible regardless of how much the page is scrolled, yet once clicked the image disappears. The code appears to work completely fine in a plain .html file.
Please help! Thank you very much in advance.
Current Console Error:
Check the jsfiddle link of your code. It works perfectly well. You just need to check the below line if the jquery 1.6.4.min.js:
<script type="text/javascript" src="http://code.jquery.com/jquery 1.6.4.min.js"></script>
This should be the right one: http://code.jquery.com/jquery-3.3.1.js
yeah, its your jquery source. have u seen a "space" in jquery src line, also you forget to close the tag. and for future dont forget to check the browser console for errors.
you can use the following fixed code in your source file.
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script>
$(window).scroll(function() {
if ($(this).scrollTop()>100) {
$('#toTop').fadeIn();
} else {
$('#toTop').fadeOut();
}
});
</script>
<style>
body{
border: 1px dotted red;
min-height: 1000px;
}
</style>
<div id="toTop">
<a style="position: fixed; bottom:20px;left:5px;" href="#ctl00_onetidHeadbnnr2" title="Back to Top">
<img style="border:1px solid red; height: 37px; width:50px" src="https://i.imgur.com/WkCCy7L.jpg" >
</a>
</div>
let me know if this fixes your error now.

Run Skrollr In IFrame

I am attempting to run some very simple Skrollr animations in an IFrame. When I populate the IFrame with the simple HTML Skrollr outputs the error to the console (in FireFox):
'Not well formed'
I have confirmed that the IFrame contents are correct and run just fine if they are not in an iframe and in a standard webpage. And I've confirmed that the Skrollr javascript file/s are loading successfully. All CSS, JS and images are all on the same domain as the parent webpage so there's no cross-domain occurring. The problem exhibits itself when the content is placed in an IFrame. Which makes me think this is a Cross-Scripting issue or that Skrollr is coded to detect cross-domain/cross-scripting?
Any idea's whats going wrong and how I can overcome this? I can provide a simple example if you wish. Hoping to grab Prinzhorn's attention, yes I know Skrollr's not currently maintained and that IFrame's are not officially supported but if I have an idea of whats going wrong or what the problem is I can fork Skrollr and add this functionality.
Edit: Heres a simple JSFiddle example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tasks</title>
<style>
#main-container {
width : 1200px;
height : 1000px;
background-color : #eee;
}
iframe {
width: 100%;
height: 100%;
overflow: scroll;
}
</style>
</head>
<body>
<div class="container text-center">
<button id="load-btn">Load Iframe</button>
<br/>
<div id="main-container" class="text-center">
<iframe id="mf-preview" frameborder="0"></iframe>
</div>
</div>
<!-- Javascript files -->
<script src="js/custom.js"></script>
</body>
</html>
everything is working brother
when the size of your iframe is more then 1000px then it will show the scroll bar
Like example :
<iframe id="mf-preview" src="http://onhax.net" frameborder="0"></iframe>
I have add the source of iframe which is larger then 1200px
and after add this like it will show the scroll bar
check it in JSFiddle

Can't move scrollbar inside of an iframe

I have an issue. I'm using this plugin for custom scrollbars, and have set it up to show up in iframe but I can't scroll on neither the Y or X axis. The content just doesn't load. (?) I have used this example and set the height to 100%. This is what I got so far:
<div id="iframecontainer" style="height: 100%; position: relative; overflow-x:hidden;
overflow-y:hidden;">
<iframe src="http://imgur.com/a/LqmeJ?gallery" scrolling="no" width="1000" height="100%" frameborder="0"></iframe>
</div>
//I use this javascript code to run the scrollbar plugin.
//I also include its files in <head> tag.
<script type="text/javascript">
$(window).load(function(){
$('#iframecontainer').mCustomScrollbar({
theme:"minimal-dark", scrollInertia: 0, axis:"yx"
});
});
</script>
I found a workaround for now, I set height to 99999px and I can scroll websites endlessly, but that's okay, because everything else works. It seems that there is no other way to fix that.

show a part of a website with iframe tag

can someone give me an example how to view only a part of a website?
I would like to show a part of a website with iframe tag (using an id or class name or ?).
how can I do?
<!DOCTYPE html>
<html>
<body>
<iframe src="http://www.w3schools.com">
<p>Your browser does not support iframes.</p>
</iframe>
</body>
</html>
you couldn't control an external page.Thus you’ve to scroll the IFRAME content to the desired position. This of course is impossible. even though there are some java script methods, but all are not really good. because scrolling occurs only when page is load.
the only one solution is You can wrap the IFRAME into a div and scroll the DIV content using absolute TOP and LEFT CSS properties.
see the example
html
<div id="frame-wrapper">
<iframe src="http://www.w3schools.com" id="my-iframe" scrolling="no"></iframe>
</div>
css
#frame-wrapper
{
width : 400px;
height : 220px;
overflow : hidden;
position : relative;
}
#my-iframe
{
position : absolute;
top : -100px;
left : -100px;
width : 400px;
height : 220px;
}
see the fiddle here

can't get my iFrame to scroll

I'm building my personal page, which is a computer with an iframe inside of it's screen with a dummy javascript terminal. My problem is that I can't get the iframe to scroll down while I keep writing on the terminal.
I've tried adding scrolling="yes" to the iframe and it doesn't work. I tried using $(document).scrollTop($(document).height()); in the iframed page and setting the height of the iframed page to 2000px... none of this worked.
This is the code of the page:
<html>
<head>
<style type="text/css">
body{
background-image:url('http://api.ning.com/files/B4MPF1W8yyhcpqgtcWbw-UuRX4aul676AQ0rB63HYNkXgQR06pGjZVwjKcwMxGgc/apple2c.big.jpg');
background-repeat:no-repeat;
}
#iframe {
position:relative;
padding-top:35px;
padding-left:144px;
}
</style>
</head>
<body>
<div id="iframe">
<iframe src="http://static.saezmedia.com/terminal/terminal/examples/rpc-demo.html" width="458" height="341" scrolling="auto"></iframe></div>
</body>
</html>
Thank you very much for your help.
In you main page: http://static.saezmedia.com/terminal/terminal/examples/rpc-demo.html you have the following css code:
jquery.terminal.css:13:
overflow:hidden;
this makes the scroll bar non visible. If you remove this the page is scrollable and then you have to automatically scroll to the bottom.
If you open it in another window, you won't be able to scroll it either.
That looks like an issue with the site.
However, you may be able to scroll it explicitly by fixing the width/height of the iframe and setting overflow auto on the containing div.

Categories