D

유트브영상 순간검색 구현

· 2011-07-13 (수) 13:31:03 · 3522 · 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,188건
+
제목 글쓴이 날짜 조회
16-03-02 조회 3,269
16-01-19 조회 2,555
15-12-23 조회 2,981
15-12-08 조회 3,716
14-10-30 조회 5,761
14-06-06 조회 5,579
12-08-30 조회 3,939
12-08-20 조회 3,861
12-07-15 조회 5,186
12-07-13 조회 3,655
12-07-06 조회 3,886
12-06-27 조회 3,394
12-06-23 조회 3,611
12-05-03 조회 5,207
12-04-20 조회 4,146
12-03-29 조회 4,666
12-03-22 조회 4,770
12-03-22 조회 3,543
12-03-21 조회 3,312
12-03-11 조회 3,731
12-03-06 조회 4,289
12-02-22 조회 4,565
12-02-17 조회 3,360
12-02-17 조회 6,217
12-02-14 조회 6,168
12-02-06 조회 4,288
12-01-18 조회 3,240
12-01-06 조회 3,464
11-12-30 조회 3,941
11-12-30 조회 7,088
11-12-21 조회 3,307
11-12-21 조회 4,274
11-12-16 조회 3,304
11-12-15 조회 3,337
11-12-15 조회 3,450
11-12-15 조회 4,253
11-12-09 조회 3,252
11-12-09 조회 3,327
11-12-07 조회 2,890
11-12-07 조회 3,980
11-12-05 조회 4,429
11-12-02 조회 3,890
11-12-01 조회 2,759
11-12-01 조회 2,813
11-12-01 조회 2,791