Created
August 4, 2011 10:43
-
-
Save kkung/1124943 to your computer and use it in GitHub Desktop.
daum image search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> | |
<script type="text/javascript" charset="utf-8"> | |
window._page = 1; | |
var fetcher = function(page) { | |
var query = ''; | |
var apikey = ''; | |
var url = 'http://apis.daum.net/search/image?q='+query+'&apikey='+apikey+'&output=json&pageno='+page+'&callback=?' | |
$.getJSON(url, function(data) { | |
var div = $("#result"); | |
div.append('<hr />'); | |
for ( var i = 0 ; i < data.channel.item.length; i++ ) { | |
item = data.channel.item[i]; | |
div.append($("<img src='" + item.image + "' />")); | |
} | |
}); | |
} | |
$(document).ready(function() { | |
fetcher(window._page); | |
}); | |
$(window).scroll(function() { | |
if ( $(window).scrollTop() == $(document).height() - $(window).height()) { | |
fetcher(++window._page); | |
} | |
}) | |
</script> | |
</head> | |
<body> | |
<div id="result"> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment