Hello, laravel web developers! In this article, we'll see how to load an iframe in jQuery on a load event. In jQuery, we'll load iframe using the onload event. The load event occurs when a specified element has been loaded.
This event works with elements associated with a URL (image, script, frame, iframe), and the window object.
Depending on the browser, the load event may not trigger if the image is cached (Firefox and IE).
<!DOCTYPE html>
<html>
<head>
<title>How to Load Iframe in jQuery onload Event - Websolutionstuff</title>
</head>
<body>
<iframe id="input_iframe" src="test.pdf"></iframe>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {
var iframe = $('#input_iframe');
iframe.on('load', function() {
info('Iframe content has loaded.');
});
});
</script>
</body>
</html>
Example:
<!DOCTYPE html>
<html>
<head>
<title>Load Video in jQuery on Window Load</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<div id="test_video"></div>
<script>
$(window).on("load", function() {
$('#test_video').prepend('<iframe src="../file/path" width="680" height="383" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>');
});
</script>
</body>
</html>
You might also like:
Hey everyone! Ever wished your Laravel application could deliver lightning-fast search results? Well, I've got great...
Feb-21-2024
In this article, we will see how to get a client's IP address in laravel 10. Here we will learn about retrieving the...
Apr-07-2023
In this tutorial, I will explain you to how to get the selected checkbox value from a checkbox list in jquery, If y...
Jun-17-2020
Hey there! If you've ever found yourself scratching your head over a forgotten MySQL root password on Ubuntu, fear n...
Jan-26-2024