Get Content From URL

by Kushal Jayswal

HTML

<select class="http-prefix">
  <option>http://</option>
  <option>https://</option>
</select>
<input class="inputbox" type="url" placeholder="site.com">

<div class="result">
  Do not enter http:// or https:// in the text input
</div>

JavaScript

$('.inputbox, .http-prefix').on('keyup change', function(){
	//alert(1);
  	$(".result").html('');
  	var urlPrefix 	= "https://crossorigin.me/",
  		httpPrefix	= $('.http-prefix').val();
  		theUrl 			= urlPrefix + httpPrefix + $('.inputbox').val();
      
	$.get(theUrl, function(data) {
      var	getTitle 	= $(data).filter('title').html(),
          getDesc 	= $(data).filter('[name=description]').attr("content"),
          $H3				= "<h3>"+getTitle+"</h3>",
          $Desc			= "<p>"+getDesc+"</p>";

      //alert(getTitle);
      //alert(getDesc);
			
      $(".result").html('');
      $(".result").append($H3);
      $(".result").append($Desc);
    });
});