I have deployed many iframes to show and hide for each tab,
<div class="slide" data-slide="1">
<iframe src="url" width="100%" height="100%"></iframe>
</div>
<div class="slide" data-slide="2">
<iframe src="url" width="100%" height="100%"></iframe>
</div>
<div class="slide" data-slide="3">
<iframe src="url" width="100%" height="100%"></iframe>
</div>
this is how its code look likes. although some buttons is not displayed.
there is the buttons matching for each iframe.
every time each buttons is clicked, then, matching iframe will be shown to user.
let's imagine that we have 100 iframes.
browser will load so many iframes. then, the users have to spend a lot of times.
so definetely I want to unload iframes until It is displyed.
how can I do that?
You can dynamically change the "src" attribute of the iframe on button click event.
Something like:
<button data-url="http://google.com">Google</button>
<button data-url="http://yahoo.com">Yahoo!</button>
<button data-url="http://aol.com">Aol.</button>
<iframe id="myFrame" src="http://google.com" width="100%" height="100%"></iframe>
Using jQuery:
$( "button" ).on( "click", function(){
var _url = $( this ).data( "url" );
$( "#myFrame" ).attr( "src", _url );
})
Doing so, you will just need a single frame element opposed to frames equivalent to no of buttons.
Related
I want two pdf scrolls side by side synchronously, following is my HTML.
<section class="text">
<div class="original">
<iframe src="/pdf/013009.pdf" id="pdf1" onscroll="scroll1();" type="application/pdf" width="100%" height="100%">
</iframe>
</div>
<div class="conversion">
<iframe src="/pdf/013009.pdf" id="pdf2" onscroll="scroll1();" type="application/pdf"
width="100%" height="100%">
</iframe>
</div>
</section>
I've found How to scroll two pdf side by side synchronously in html? and trying to solve my problems, but having a hard time understanding the solution, such as $("#pdf1").contents().find("#viewerContainer").on('scroll', function(){...}where did #viewerContainer come from.
this is my JQ:
$("#pdf1").on('load', function () {
$("#pdf1").contents().find(".original").on('scroll', function () {
$("#pdf2").contents().find(".conversion").scrollTop($(this).scrollTop());
});
$("#pdf2").on('load', function () {
$("#pdf2").contents().find(".conversion").on('scroll', function () {
$("#pdf1").contents().find(".original").scrollTop($(this).scrollTop());
});
});
});
i don't really understand .find(""), so ".conversion", ".original" were my guess.
now, both of the pdf scroll correctly, but they did not scroll synchronously,
anyone who could help with this situation will be appreciated.
thanks!
Vimeo player will now play even with allow="autoplay" attribute, check jsfiddle console error, click small icon play button:
https://jsfiddle.net/0vfLtdm8/
var player = document.getElementById('video-player');
var vimeoPlayer = new Vimeo.Player(player);
playbtn.onclick = function() {
vimeoPlayer.play();
}
vimeoPlayer.on('error', function(error) {
console.log(error);
});
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
<script src="https://player.vimeo.com/api/player.js"></script>
<div id="video-outer-full">
<div id="video-inner">
<i class="far fa-play-circle" id="playbtn"></i>
<iframe id="video-player" class="video" width="560" height="315" src="https://player.vimeo.com/video/309741585" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen allow="autoplay"></iframe>
</div>
</div>
#Toniq this is an issue specific to jsfiddle and codepen like services.
On those test pages they wrap the user defined test content in an iframe which doesn't have the allow="autoplay" which prevents the play() action from happening.
Also the Vimeo player iframe has to have the allow="autoplay" attribute.
You can see on the api demo page that this problem doesn't occur if you press the custom play button on the top right.
https://player.vimeo.com/api/demo
I am new to HTML and i don't know JavaScript.I want embed a badge to my website using iframe tag <iframe src="URL" width="500" height="50" frameborder='0' align='middle'> and when some one clicks on it,i want to open a website in a new tab.
I tried adding <a> tag around frame tag but only the borders of frame are hyper linked not the badge . how do I link the badge embedded in an frame to a new site?
Working Answer :
NOTE : Onclick will take you to go to google.com in new tab. This You can click only once. The Listener resets on refreshing the main page again.
<script type="text/javascript">
focus();
var listener = window.addEventListener('blur', function() {
if (document.activeElement === document.getElementById('myFrame')) {
var win = window.open('https://www.google.com', '_blank');
win.focus();
}
window.removeEventListener('blur', listener);
});
</script>
<iframe id="myFrame" src="https://www.codewars.com/users/balajis/badges/large" width="500" height="50" align='middle' frameborder='0'">
Add your Badge as a image.
<a href="NEW_SITE_URL" target="_blank">
<img width="220" height="250" border="0" align="center" src="BADGE_URL"/>
</a>
I'm trying to change the 'display' CSS property of a div when the video I have on my page finishes playing. I've tried different methods: adding an eventhandler, and listening for the end event in a separate <script> tag (under the window.onload block). I'm trying a third option but can't get it to work either:
in the body:
<div id="feels_feel_container">
<div id="AnswersWrapper" style="display: none">
Some stuff here.
</div>
<div id="VideoWrapper">
<video id="VideoWindow" src="../html/media/homepage.mp4" autoplay onended="VideoEnded()"/>
</div>
</div>
in the head:
<script>
function VideoEnded() {
AnswersWrapper.css("display", "block");
}
</script>
What am I doing wrong?
Found out that I was calling an invalid argument in my VideoEnded() function.
I should've put $("#AnswersWrapper) instead of AnswersWrapper.
Please ignore :)
I want to call a function in my index page which is available at "phone gap file", I have called my index page inside phone gap file with in a frame.
Current code working in web but not in application,Please any one suggest me
//code inside phonegap
function clickImage(){
alert("Phonegap app");
}
//Code inside normal html
function clickPicture(){
window.parent.clickImage();
}
index.html
_______________
<body>
<button onclick="clickPicture();">Take Picture</button>
</body>
Phonegap.html
_____________
<iframe id ="Qusframe" src="index.html" width='100%' scrolling='no' frameBorder='0' >
<p> Your browser does not support iframes. </p>
</iframe>