IE标题更改为<afterHash>,如果页面的网址为"#",并且其中嵌入了flash/swf

Nee*_*raj 24 browser flash jquery internet-explorer-8 internet-explorer-7

问题是,如果IE(6.0+)中嵌入了flash内容,并且页面的url中有一个#where,那么当加载flash内容时,或者如果用户与之交互,则标题为窗口,更改散列后的内容.

例如http://adobeflashwebsite.com/index.html#somediv

然后页面标题变为'somediv',用户点击flash内容的时刻,或者甚至闪存内容加载的那一刻.

这只发生在IE中.

以下是我面临的一个非常具体的案例:

以下是我面临的问题:

  1. 调整引擎以显示类似iGoogle的页面
  2. Sammy.js
  3. 小工具渲染flash/swf

这里的问题是,无论我尝试嵌入闪存的哪个插件,我最终都遇到以下问题

  1. 当flash完全加载时,它会附加类似#tab/xx的内容,它实际上是sammy用来存储页面中最后一个导航历史记录的字符串
  2. 当用户开始与闪存进行交互时,标题将被完全删除,并且只有#tab/xx保留为标题.
  3. 刷新小工具时,即使这样,也会出现类似#2的问题.

有人可以建议,问题可能是什么?最有可能的是它与sammy.js有关,因为iGoogle没有这个问题.

Nee*_*raj 18

以下解决方法是唯一的方法(到现在为止),我最接近解决问题:

var isIE11OrGreater = !!(navigator.userAgent.match(/Trident/) && !navigator.userAgent.match(/MSIE/));
if (!isIE11OrGreater) {
    var originalTitle = document.title.split("#")[0];    
    document.attachEvent('onpropertychange', function (evt) {
       if(evt.propertyName === 'title' && document.title !== originalTitle) {
        setTimeout(function () {
           document.title = originalTitle;
        }, 1);
    }
});

}

//Incase the developer wants to change the title manually, instead of directly using     //document.title=newtitle, he will need to use changeTitle(newTitle)
    function changeTitle(newTitle)
    {
        originalTitle = newTitle;
        document.title = newtitle;
    }
Run Code Online (Sandbox Code Playgroud)


Hei*_*kki 8

这是IE错误:

如果你使用sammy的title方法,你可以延迟执行一点,使其在IE上运行.

setTimeout(function() {
    context.title('Some title');
}, 1000);
Run Code Online (Sandbox Code Playgroud)

这不会真的解决它,但我注意到有点延迟有助于IE.