Javascript 检测iframe源是否有';相同的源代码';保护

Javascript 检测iframe源是否有';相同的源代码';保护,javascript,Javascript,我得到了一个脚本,用于检查存储在txt文件中的多个URL的加载时间: $.get("imones.txt", function (data) { var array = data.split(/\r\n|\r|\n/) var beforeLoad = (new Date()).getTime(); var loadTimes = []; var beforeTimes = [];

我得到了一个脚本,用于检查存储在txt文件中的多个URL的加载时间:

$.get("imones.txt", function (data) {
        var array = data.split(/\r\n|\r|\n/) 
        var beforeLoad = (new Date()).getTime();    
        var loadTimes = [];
            var beforeTimes = [];               
        $('#frame_id').on('load', function () {                                 
            beforeTimes.push(beforeLoad);
            loadTimes.push((new Date()).getTime()); 
            $('#frame_id').attr('src', array.pop());
                $.each(loadTimes, function (index, value) { 
                    var result = (value - beforeTimes[index]) / 1000;
                        if (result < 0) {
                            result = result * (-1);
                        }   
                    $("#loadingtime" + index).html(result);
                    beforeLoad = value;
                });
        }).attr('src', array.pop());
    });

所以,是的,在我计算加载时间之前,我可以看看某个特定的url是否会给我“相同的源代码”错误吗?

如果你不能读取iframe的
src
属性,那么你有一些不来自同一域的内容

<iframe src="./" height="300" width="300" name="example"></iframe>
<input type="button" onclick="alert(document.getElementsByName('example')[0].src);" value="test" />
<a href="http://www.google.com" target="example">click me</a>


上面的代码应该给你一个想法。但是,这段代码在JSFIDLE上不起作用。

是的,我因此得到了“相同的源代码”错误,并且它使列表中其他url的所有计算都崩溃,我不想加载给我“相同源代码”的url,我只想加载我的其他urlload@user1894929你有没有试着使用试抓挡块?
<iframe src="./" height="300" width="300" name="example"></iframe>
<input type="button" onclick="alert(document.getElementsByName('example')[0].src);" value="test" />
<a href="http://www.google.com" target="example">click me</a>