I have a script that takes urls from an array, then puts them into an iframe one after another:
<script type="text/javascript">
$(document).ready(function () {
var array = ['http://www.example1.come', 'http://www.example2.com', 'http://www.example3.com'];
var beforeLoad = (new Date()).getTime();
var loadTimes = [];
$('#1').on('load', function () {
loadTimes.push((new Date()).getTime());
$('#1').attr('src', array.pop());
if (array.length === 0) {
$.each(loadTimes, function (index, value) {
$("#loadingtime" + index).html(value - beforeLoad);
});
}
}).attr('src', array.pop());
});
</script>
My problem is, if i put url like "google.com", or "youtube.com" - it wont load thus making the other sources stuck and not load too. I am getting this error on chrome console mode if i try to put google.com as a source into iframe : Refused to display 'http://www.google.com/' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.
How can i make it so if theres such an url in my url list that gives this error and wont load, it would skip that url and load the next one instead? can i put a timeout or something?