HTML5 and Javascript to play videos only when visible
Using the isInViewport plugin and jQuery, here’s my code for the task $(‘video’).each(function(){ if ($(this).is(“:in-viewport”)) { $(this)[0].play(); } else { $(this)[0].pause(); } })
Using the isInViewport plugin and jQuery, here’s my code for the task $(‘video’).each(function(){ if ($(this).is(“:in-viewport”)) { $(this)[0].play(); } else { $(this)[0].pause(); } })
Yeah, there are many, many ways a page’s layout can alter between loads. Different window sizes, different font sizes, different font availability, different browser/settings (even a small change in layout or font preference can throw out the wrapping). Storing page-relative co-ordinates is unlikely to be that useful unless your page is almost entirely fixed-size images. … Read more
You should be able to override Event.prototype.preventDefault and add a debugger statement as its first line. Run the following via the console. var oldEPD = Event.prototype.preventDefault; Event.prototype.preventDefault = function() { debugger; oldEPD.call(this); };
I know I am pretty late to the party, but in case you did not figure it out yet, you can keep the action and make sure the form is not actually submitted by passing $event to the ng-submit function. Then you can use event.preventDefault(); in your controller after you do all your processing. So … Read more
var min = -10; var max = 10; // and the formula is: var random = Math.floor(Math.random() * (max – min + 1)) + min;
Why not just let jQuery do it? var content = “<p>Dear sms,</p><p>This is a test notification for push message from center II.</p>”; var text = $(content).text();
This is what you want: function ltrim(str) { if(!str) return str; return str.replace(/^\s+/g, ”); } Also for ordinary trim in IE8+: function trimStr(str) { if(!str) return str; return str.replace(/^\s+|\s+$/g, ”); } And for trimming the right side: function rtrim(str) { if(!str) return str; return str.replace(/\s+$/g, ”); } Or as polyfill: // for IE8 if (!String.prototype.trim) … Read more
2018 update: Confirmed on Version 65.0.3325.181, you can simply right-click anywhere inside the devtools console and click “Clear console history.” It solved the problem for me. I ran into this issue earlier and, having never seen it before, began going through the first couple steps to TarranJones’ solution.
Try with this: var url = “https://site.com”; var urlNoProtocol = url.replace(/^https?\:\/\//i, “”);