ニコニコ動画埋め込み用
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja"> <head> <meta http-equiv="Content-Script-Type" content="text/javascript"/> <meta http-equiv="Content-Style-Type" content="text/css"/> <meta http-equiv="content-language" content="ja,jp-ja"/> <meta charset="UTF-8"/> <title>ニコニコ動画</title> <script type="text/javascript"> var targetMovie; document.addEventListener( 'DOMContentLoaded',function() { targetMovie = window.location.href.split("#"); if(targetMovie.length < 2)return; targetMovie = targetMovie[1]; var movieBlock = document.getElementById("niconico"); var width = window.innerWidth; var height = window.innerHeight; if(width < 1)resizePlayer(); createMovieScript(targetMovie,width,height,movieBlock); window.addEventListener("resize", function() { var movieBlock = document.getElementById("niconico"); var width = window.innerWidth; var height = window.innerHeight; createMovieScript(targetMovie,width,height,movieBlock); }); }); function resizePlayer(){ var width = window.innerWidth; if(width > 0){ var movieBlock = document.getElementById("niconico"); var height = window.innerHeight; createMovieScript(targetMovie,width,height,movieBlock); }else{ setTimeout(resizePlayer,50); } } function createMovieScript(id,w,h,block){ block.innerHTML = ""; var scriptE = document.createElement("script"); scriptE.setAttribute("type","text/javascript"); scriptE.setAttribute("src",'http://ext.nicovideo.jp/thumb_watch/'+id+'?w='+w+'&h='+h); block.appendChild(scriptE); var nScript = document.createElement("noscript"); nScript.innerHTML = '<a href="ht'+'tp://ww'+'w.nicovi'+'deo.jp/watch/'+id+'">【ニコニコ動画】</a>'; block.appendChild(nScript); } </script> </head> <body> <div id="niconico"></div> </body> </html>
page revision: 31, last edited: 14 Jan 2018 12:54