function redirectToLatestChannelVideo(){ var youtube_channel_data_url = "https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UCeL5TtjthW8_3Jnr_opd7iw&maxResults=1&order=date&type=video&key=AIzaSyBMeQjvor3tPmzRhf3kFqOjZnO9KxOZ_kg"; $.getJSON(youtube_channel_data_url, function(data){ var id = data.items[0].id; var page_url = "https://www.youtube.com/watch?v="+id; window.location.replace(page_url); } ); } redirectTolatestChannelVideo();