D

유트브영상 순간검색 구현

· 2011-07-13 (수) 13:31:03 · 3535 · 9
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="">
<meta name="keywords" content="">
<meta name="history" content="">
<meta name="author" content="[email protected]">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.2.min.js"></script>
<title>유트브 순간검색</title>
<script type="text/javascript">
$(document).ready(function()
{

$(".search_input").keyup(function()
{
var search_input = $(this).val();
var keyword= encodeURIComponent(search_input);
var yt_url='http://gdata.youtube.com/feeds/api/videos?q='+keyword+'&format=5&max-results=1&v=2&alt=jsonc';
$.ajax
({
type: "GET",
url: yt_url,
dataType:"jsonp",
success: function(response)
{
if(response.data.items)
{
$.each(response.data.items, function(i,data)
{
var video_id=data.id;
var video_title=data.title;
var video_viewCount=data.viewCount;
var video_frame="<iframe width='640' height='385' src='http://www.youtube.com/embed/"+video_id+"' frameborder='0' type='text/html'></iframe>";
var final="<div id='title'>"+video_title+"</div><div>"+video_frame+"</div><div id='count'>"+video_viewCount+" Views</div>";
$("#result").html(final); // Result
});
}
else
{
$("#result").html("<div id='no'>No Video</div>");
}
}
});
});
});
function yts(search_input){
var keyword= encodeURIComponent(search_input);
var yt_url='http://gdata.youtube.com/feeds/api/videos?q='+keyword+'&format=5&max-results=1&v=2&alt=jsonc';
$.ajax
({
type: "GET",
url: yt_url,
dataType:"jsonp",
success: function(response)
{
if(response.data.items)
{
$.each(response.data.items, function(i,data)
{
var video_id=data.id;
var video_title=data.title;
var video_viewCount=data.viewCount;
var video_frame="<iframe width='640' height='385' src='http://www.youtube.com/embed/"+video_id+"' frameborder='0' type='text/html'></iframe>";
var final="<div id='title'>"+video_title+"</div><div>"+video_frame+"</div><div id='count'>오늘까지뷰 "+video_viewCount+" Views</div>";
$("#result").html(final); // Result
});
}
else
{
$("#result").html("<div id='no'>No Video</div>");
}
}
});
}
yts('Empire State of Mind');
</script>
</head>
<body>
<div id="wrap">
<h2>DOKJIN PLAY GROUND</h2>
<div id="result"></div>
<h2>검색어를 입력하세요 <input type="text" class='search_input' /> </h2>
<br />
<h2><a href="#" onclick="yts('아이유');">onclick="yts('아이유');"</a></h2>
<ul>
</div>
</body>
</html><div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 16:57:14 JavaScript에서 이동 됨]</div>

첨부파일

youtube.html (2.7 KB) 86회 2011-07-13 13:31
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

8,187건
+
제목 글쓴이 날짜 조회
16-07-13 조회 2,181
16-07-12 조회 2,369
16-07-12 조회 2,397
16-07-11 조회 2,212
16-06-05 조회 2,933
16-06-03 조회 3,074
16-05-26 조회 2,998
15-09-22 조회 5,002
15-06-10 조회 4,855
14-10-25 조회 6,385
14-10-22 조회 9,004
14-09-21 조회 5,813
14-09-16 조회 5,097
14-08-22 조회 1.1만
14-08-13 조회 5,943
14-08-12 조회 5,454
14-08-12 조회 6,324
14-08-11 조회 6,961
14-06-12 조회 6,234
14-06-11 조회 5,129
14-05-09 조회 5,468
14-05-09 조회 6,423
14-05-09 조회 6,443
14-05-08 조회 5,787
14-04-17 조회 4,800
14-04-16 조회 4,611
14-04-15 조회 4,607
14-04-15 조회 4,552
14-04-15 조회 4,328
14-04-14 조회 4,319
14-04-14 조회 4,292
14-04-14 조회 4,653
14-04-14 조회 4,805
14-04-14 조회 4,796
14-04-13 조회 4,707
14-04-12 조회 4,264
14-04-12 조회 4,402
14-04-12 조회 4,505
14-04-11 조회 5,022
14-04-10 조회 4,771
14-04-10 조회 4,803
14-04-09 조회 4,955
14-04-09 조회 5,336
14-04-08 조회 7,022
13-10-30 조회 7,676
13-07-11 조회 5,161
13-03-28 조회 1.1만
13-02-27 조회 6,803
13-02-14 조회 5,657
13-01-10 조회 4,539
12-12-31 조회 5,127
12-12-20 조회 6,135
12-12-12 조회 5,294
12-12-07 조회 4,537
12-11-28 조회 4,895
12-11-22 조회 5,332
12-11-12 조회 5,689
12-09-22 조회 4,534
12-09-18 조회 4,721