Skip to content

Instantly share code, notes, and snippets.

@cesarkohl
cesarkohl / youtube-pause.js
Last active January 17, 2018 19:06 — forked from cferdinandi/stop-video.js
Youtube Pause Video
var youtube_video = $('iframe');
var url = youtube_video.attr('src'); // 1. First get the iframe URL
youtube_video.attr('src', ''); // 2. Then assign the src to null, this then stops the video been playing
youtube_video.attr('src', url); // If you need to reassign the URL back to your iframe, so when you hide and load it again you still have the link
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if !IE]><!--> <html lang="en"> <!--<![endif]-->
/*
* 判斷按下的按鈕是哪一個
* @param (event) e keypress event.
* @param (mix) targetKeyChar 按鍵的編號或名稱,如果是這個按鍵,就執行 callback
* @param (function) callBack 送入callback的function,不用加()括號
*
*/
var detectKeyPress = function(e, targetKeyChar, callBack){
var keynum