I have noticed there are a few questions that have been asked on the above topic, however, there hasn't been one for embedded videos. I was hoping someone would be able to help.
Note: My first post - so apologies if i haven't provided the appropriate information!
<script type="text/javascript">
jQuery(document).ready(function($) {
$(".container-fluid").on('click','#issuuclick',function(){
alert("it's working")
})
});
</script>
<div data-configid="26360926/39969074" style="width:525px; height:373px;margin: 0 auto;" class="issuuembed" id="issuuclick"></div><script type="text/javascript" src="//e.issuu.com/embed.js" async="true"></script>
the above is my html embedded and javascript code. The aim here is to automatically open the publication in full spread when the page loads but only the alert is popping up at the moment (I have used a timer).
Would appreciate some assistance!
Try
$(document).ready(function(){
$("#issuuclick").trigger("click");
});
//or
window.onload = function() {
$("#issuuclick").trigger("click");
};
The first example fires as soon as the document is ready to work with and the second example fires when the page is ready and ALL resources are loaded
And attach a click handler to "#issuuclick" like
$(document).on("click", "#issuuclick", function(){
// do something
});
Related
I have an iframe inside my page.
<iframe id="iframe" src="myurltopage" name="iframe" title="..." overflow-y='scroll' overflow-x='hidden'></iframe>
<div id="spinner"><h3><i class="fa fa fa-spinner fa-spin"></i></h3></div>
I add a spinner on basic-HTML, and inside a function to hide it, if the iframe is the load.
$(document).ready(function(){
$('#iframe').on('load', function()
{
$('#spinner').fadeOut();
}
});
Sometimes, the spinner won't hide even though I see the page is correctly loaded and in the console, I cannot see any open loading processes. I have to reload the page one times, sometimes more, than all works fine.
Did anyone have an idea what it can cause and/or how I prevent this issue?
Thanks a lot.
If you want to hide spinner when all the content is ready on the page (means all the resources are downloaded like images, fonts, css, scripts, iFrames etc) then you can use following code. If you want hide spinner when only that iFrame is loaded please refer the link which I have also entered in the comment.
$(window).on('load', function() {
$('#spinner').fadeOut();
});
Based on the linked info in the comments of the question, from Rahul Raut, i decide to solve it in this way
var init=false;
$(function () {
var innerDoc = ($("#iframe")[0].contentDocument) ? $("#iframe")[0].contentDocument:$("#iframe")[0].contentWindow.document;
innerDoc.onreadystatechange = function () {
if(init==false){ alert("Go"); }
if ($('#spinner').is(":visible") == true){ $('#spinner').fadeOut(); }
return;
};
setTimeout(innerDoc.onreadystatechange, 3000);
});
I'm trying to use a script called Socialite in my Wordpress site to make social share buttons appear only after the user has moved his/her mouse AND the document already loaded.
I can't get it to work together. My current script, that does work, is:
jQuery(document).one("mousemove", function() {
var social_container = jQuery('.social_buttons');
Socialite.load(social_container);
});
But how do I connect the document load part?
Thanks
Have you tried to put your code into
jQuery(document).ready(function(){/* your code goes here*/});
?
For starters you have a small typo in the first line
jQuery(document).one("mousemove", function() {
You're calling .one("mous...
It should be .on("mous...
Next considerations is that the document ready statement below will happen before images etc have loaded
$(document).ready(function(){
// your code goes here.....
});
using a window load statement like below waits until everything i.e.images have loaded in full
$(window).load(function(){
// code here.....
});
I'm not sure what would suit your needs best as I have no experience with Socialite but hopefully this will give you the answers you need.
I am trying to force a user to first fill a form which will be in a un-closable modal and once the user enters the data he can get access to the website.
I am refering to this example.
-Example 5: the un-closable window
The modal is working exactly the way I want it but I am unable to make it load with the page.
I dont understand Javascript much thus I am stuck here.
I tried using this -
<script type="text/javascript">
$(document).ready(function() {
$("#ex5").dialog({modal: true});
});
</script>
But this didn't work.
Any help would really be appreciated.
Also please suggest any other un-closable popup modal which I can use instead of the one I have mentioned.
According to the jQuery UI Documentation, you can add the no-close class to the modal dialog to hide the close button.
Also, if your javascript is running too soon with $(document).ready(), you could try $(window).load().
Code included inside $( document ).ready() will only run once the page
Document Object Model (DOM) is ready for JavaScript code to execute.
Code included inside $( window ).load(function() { ... }) will run
once the entire page (images or iframes), not just the DOM, is ready.
http://learn.jquery.com/using-jquery-core/document-ready/
So you could try something like this, and make sure that there is an element with id="ex5".
<script type="text/javascript">
$(window).load(function() {
$("#ex5").dialog({modal: true,
dialogClass: 'no-close'});
});
</script>
Use this code to open modal with page load
<script type="text/javascript">
$(document).ready(function() {
$('#ex5').modal('show');
});
</script>
You find the detailed instructions about Bootstrap modal here http://getbootstrap.com/javascript/#modals
you Have to code like this, refer this coding,
$(document).ready(function () {
var outerThis = this, isCloseable = false;
$('#close-button').on('click', function (e) {
e.preventDefault();
if(outerThis.isCloseable) {
$('#ex5').hide();
outerThis.isCloseable = false;
}
});
});
I have been asked to put in place disabling of the right clicks on a website, I've informed them there is so many ways that people can still download the images via Google Images, Cache, Firebug etc etc, but none the less my arguments have gone ignored and they insist this must be done.
Any, I've put in the footer some code that disables right clicking on all elements using <IMG src=""> this fails to work on NivoSlider, I did change the script to use window load on disabling the right click which works but after slide1 it stops working and I assume this is something to do with changes to the DOM.
JavaScript is by far my weakest point and I'm hoping that someone without to much trouble can either give me a full working solution or something to go on. Thanks in Advance.
They are using NivoSlider with the following trigger:
<script type="text/javascript">
(function($) {
$(window).load(function() {
$('#slider').nivoSlider();
});
})(jQuery);
</script>
And this is the code that I've placed in the footer that fails to work on slide2+
<script>
$(window).load(function() {
$('img').bind('contextmenu', function(e) {
return false;
});
});
</script>
You're absolutely right with the DOM changes. You need to delegate the event to a parent element.
Try something like this:
$('#slider').delegate('img', 'contextmenu', function(e) {
return false;
});
Or this if using jQuery > 1.7:
$('#slider').on('contextmenu', 'img', function(e) {
return false;
});
You might be able to do it by preventing the default behaviour of a right click on the image.
See this answer: How to distinguish between left and right mouse click with jQuery
I have the following scenario..
When the user visit my website I show the user some audio files from the server. When the user clicks on one link, then the jquery function is eventually executed and change the source of the embedded object to selected file.
The codes are given in this link.
I got some answers for this question but the problem isn't solved.
What happening for me is, When I click on the link. The song plays in new page. I need to play the song with embedded object inside the div.
Try this:
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$(function(){
$(document).on('click', "#song", function(e){
e.preventDefault(); //<----------stops to navigate to link
var musicSrc = $(this).attr('href');
$('#music').find('embed').attr('src', musicSrc);
});
});
</script>
note:
make sure to load the jQuery library first:
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
Well of course it's not working. The event should be added after the page loads. Using jquery, it would look like this :
<script type="text/javascript">
$(function () {
$(".song").click(function(e) {
$('#mplayer').attr('src', $(this).attr('href'));
e.preventDefault();
});
});
</script>