D

유트브영상 순간검색 구현

· 2011-07-13 (수) 13:31:03 · 3526 · 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건
+
제목 글쓴이 날짜 조회
12-01-11 조회 2,786
12-01-11 조회 1.2만
12-01-10 조회 2,883
12-01-08 조회 3,475
12-01-05 조회 5,363
11-12-29 조회 3,084
11-12-27 조회 2,874
11-12-25 조회 3,058
11-12-22 조회 3,491
11-12-14 조회 2,950
11-12-12 조회 3,585
11-11-28 조회 3,413
10-10-19 조회 2,864
08-09-05 조회 3,777
08-09-05 조회 3,596
08-06-14 조회 3,339
08-04-22 조회 3,621
08-04-17 조회 3,632
07-10-03 조회 4,230
07-10-03 조회 3,628
07-10-03 조회 7,308
07-10-03 조회 4,591
07-10-03 조회 3,294
07-10-03 조회 2,883
07-10-02 조회 3,597
07-10-02 조회 3,122
07-09-27 조회 5,048
07-09-27 조회 3,889
06-09-26 조회 3,534
06-09-26 조회 4,754
06-09-22 조회 3,929
06-09-22 조회 3,544
06-09-22 조회 4,296
06-09-21 조회 4,225
06-08-18 조회 3,716
05-11-30 조회 4,765
05-07-15 조회 4,624
05-03-23 조회 4,665
05-03-14 조회 3,335
05-03-13 조회 2,707
04-08-05 조회 5,788