I created simple jquery mobile website, where you click an button and iframe with video is loaded on popup.
My problem is that video keeps playing after i close the popup.
How can i avoid this?
Jquery mobile documentation says that this will happen, and i should listen to popupafterclose event.
http://demos.jquerymobile.com/1.2.0/docs/pages/popup/popup-iframes.html
But how can i do that, can someone make me an example?
Demo of problem: http://jsfiddle.net/43nk572m/1/
HTML:
<!-- BUTTONS -->
Open Iframe Popup1
Open Iframe Popup2
<!--POPUPS-->
<div data-role="popup" id="testing" data-theme="b" data-tolerance="15,15">
Close
<div data-role="header">
<h1>blablabla</h1>
</div>
<iframe src="http://player.vimeo.com/video/110823244" width="520" height="360" scrolling="no" seamless="seamless"></iframe>
</div>
<div data-role="popup" id="testing2" data-theme="b" data-tolerance="15,15">
Close
<div data-role="header">
<h1>blablabla</h1>
</div>
<iframe src="http://player.vimeo.com/video/110823244" width="520" height="360" scrolling="no" seamless="seamless"></iframe>
</div>
Please note that popup div id is always changing so i cant just call some javascript to kill #testing2 for example.
I appriciate your help!
Regards
M
You should try something like this:
$("#testing").bind({
popupafterclose: function(event, ui) {
$(this).find('iframe').remove();
}
});
For the popup div, you can use the jQuery selector '[data-role="popup"]'. To catch the popupafterclose event, delegate it from the document, so that any dynamically created popups will trigger the event:
$(document).on( "popupafterclose", '[data-role="popup"]', function( event, ui ) {
$(this).find("iframe").prop("src", "");
});
In the event handler, find the iframe element and set its src prop to an empty string.
DEMO
Related
When I close my modal, the video keeps playing in the background. It is a really small program with only HTML and CSS, so I don't want to use the YouTube API. This is my modal code:
<div id="lucaModal" class="modal modal-fullscreen" role="dialog">
<button id="lucaButton" class="btn btn-danger closeIFrame" data-dismiss="modal">
CLOSE
</button>
<div class="modal-content">
<iframe class="trailer" id="trailer" title="YoutubeVideoPlayer"
style="height: 100%; width: 100%;"
src="https://www.youtube.com/embed/mYfJxlgR2jw" frameborder="0">
</iframe>
</div>
</div>
I tried jQuery, but my modal wouldn't close this way:
$(document).ready(function(){
$("#lucaModal").modal('show');
$("#lucaButton").click(function(){
$("#lucaModal").modal('hide');
});
});
So I've played around with your code and found a way around this.
Below I used JQuery to solve your.
//below is click detector that checks if the user has clicked anywhere
$('body').on('click',function(){
//if the modal is no longer visible on the screen
if(!$('#lucaModal').is(':visible')){
//we get the src of the current video
var trailer = $('#trailer').attr('src');
//and reset it, that will sort out your problem
$('#trailer').attr('src',trailer);
}
});
Just copy and paste the code above to your js file and see if it works. If it does then play around with it, maybe you can create an even better way of handling this issue.
Thanks.
I have Iframe embed external website to my website but my text, button and content is very large.
Image of my content:
The content's code:
<div class="row-container">
<div class="poker_content" [ngClass]="{'not-opened': iframeUrl === null}">
<iframe [src]="iframeUrl | safe" *ngIf="showIframe"></iframe>
</div>
</div>
How can I manipulate the content?
Styling the contents of an iframe is just like styling any other web page. But, you must have access to edit the page. If you can't edit the page (for example, it's on another site).
If you can edit the page, then you can add an external style sheet or styles right in the document just like you would style any other web page on your site.
Reff. - https://www.lifewire.com/iframes-and-css-3468669
just take the content with php (php bot)
add class to buttons after content is loaded jquery ile
Example Jquery;
$("#fancybox-frame").load(function(){
$('#fancybox-frame').contents().find("a").css("background-color","#BADA55");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<iframe frameborder="0" scrolling="auto" src="http://www.uzatmabirader.com/Dunya" hspace="0" name="fancybox-frame1302993380315" id="fancybox-frame"></iframe>
Does anybody know of a non Javascript youtube video pop up. I have a button on my homepage which I want to open a pop up with a youtube video inside.
Thanks guys
this is my link
<span class="cta floatL">through the eyes of a bigsmile advert</span><span class="playIco floatL"></span>
this is my iframe
<iframe width="420" height="345" src="<iframe width="420" height="345" src="http://www.youtube.com/embed/krlR2-YGk4sI?autoplay=1" frameborder="0" allowfullscreen></iframe>" frameborder="0" allowfullscreen></iframe>'
I just need to find a way to make it pop up in the center of the screen like a fancybox, without javascript. Thanks guys
no i dont think there is a method without using JS but it is very simple with JS for a piece like this. you should just be able to place the popup in a div and then use CSS to make it hidden then on the button click a JS function that will bring it to the top.
Hope this helps :)
<div id='PopUp' style='display:none;'>
<iframe></iframe>
</div>
<button onclick='showPopUp()'>click Me</button>
<script>
function showPopUp()
{
document.getElementById('PopUp').style.display = 'block';
}
</script>
I have a youtube video pop up that works well but I want to include a custom close button. I have done research but this has all come to nothing so I am hoping my stack buddies can help.
What I am estmiating from your question is you want a custom close button to close the DIV or iframe that your YouTube videos are in. I suggest jQuery for this:
$(function(){
$(".closeBtn").click(function(){
$($(this).data("target")).hide();
});
});
Then in the HTML:
<div class="video" id="v1">
<div class="closeBtn" data-target="#v1"></div>
<iframe></iframe>
</div>
JS Fiddle
What the data-target (data-target="#v1") does is target the ID of the div (<div class="video" id="v1">) then in jQuery, adding the animation effect .hide() , .fadeOut(500) to the ID.
i have an iframe that supposed to show me the pages according to the links.
the iframe code is :
<iframe width=940px onload=reSize() src="src/HEB/registerHEB.html" id="ifrm" name="iframe_main" frameborder="0" scrolling="no"></iframe>
i want to do that when i click on link such as this one
<a href="html/guides.html" target="iframe_main">
it will open the page in the iframe, but when i click F5 (refresh) it won't load the original src of the iframe, but the last link ive clicked.
Thank you very much.
use this script after iframe same as:
<iframe src="src/HEB/registerHEB.html" id="ifrm" ......></iframe>
<script>
document.getElementById("ifrm").src = 'src/HEB/registerHEB.html';
</script>