Ajax对象IE:Youtube视频未正确加载

时间:2014-08-24 19:50:46

标签: javascript ajax internet-explorer youtube

在我的网站上正常加载第一页后,我使用javascript ajax(ajaxObject)请求所有其他页面的正文内容。
我只是用ajaxObject(javascript)抓取body innerHTML并替换实际的:

<script type="text/javascript">
function get(url) {
    var myRequest = new ajaxObject(url, uGotAResponse);
    myRequest.update('','GET');
}
function uGotAResponse(responseText,responseStatus) {
    //Create a temp div to be able to use getElementById on it.
    var theTempDiv = document.createElement('div');
    //put the grabbed body innerHTML into it.
    theTempDiv.innerHTML = responseText;
    //my pages are like <body><div id="divcontent">content of pages here</div></body>
    //so i get that div containing the innerHTML i really need.
    var allDiv = theTempDiv.getElementsByTagName('div');
        for (var i=0; i<allDiv.length; i++) {
            if (allDiv[i].getAttribute('id') == 'divcontent') {
                //i now replace the actual body innerHTML by the one i requested.
                document.getElementById('divcontent').innerHTML=allDiv[i].innerHTML;
            }
        }
    }
</script>

在页面上,我有嵌入视频的youtube对象:

<object type="application/x-shockwave-flash" data="http://www.youtube.com/v/1ahKNnolR30" height="315px" width="420px"><param name="movie" value="http://www.youtube.com/v/1ahKNnolR30"></object>

在Firefox中,如果我使用地址或使用ajax代码加载页面,一切都很好。

使用IE浏览器,仅当我使用地址转到页面时才有效 当我尝试使用ajax代码时,视频显示为下图。 我用IE测试器试了一下,所有版本都给了我相同的错误行为。

有没有人可以解决这个问题?

Youtube video fails to load; blank(white) container.

正如你所看到的,它看起来像对象视频,但看起来IE并没有解释它,因为它是由ajax加载的。

0 个答案:

没有答案