问题描述
问题是,如果IE(6.0+)中嵌入了Flash内容,并且页面的url中的某个位置带有#号,则当加载Flash内容时,或者如果用户与之交互,则窗口的标题,更改为哈希后的内容.
The issue is, if IE (6.0+) , has flash content embedded in it, and the url of the page has a # somewhere in it, then when the flash content loads ,or if the user interacts with it, then the title of the window, changes to the content that is places after hash.
例如 http://adobeflashwebsite.com/index.html#somediv
然后,页面标题更改为'somediv',即用户单击Flash内容的那一刻,或者甚至多次加载Flash内容的那一刻.
Then the title of the page changes to 'somediv' , the moment a user will click on flash content, or many a times even the moment the flash content loads.
这是我面临的一个非常具体的情况:
This below is a very specific case I was facing:
以下是我遇到问题的环境:
The following is the environment I am facing issues with:
- 关闭引擎以显示类似iGoogle的页面
- Sammy.js
- 渲染Flash/swf的小工具
这里的问题是,无论我尝试使用哪个插件嵌入Flash,最终都会遇到以下问题
The issue here is, no matter which plugin I try to embed flash with, I end up having the following problem
- 当Flash完全加载后,它会附加#tab/xx之类的内容,实际上是sammy使用的字符串,用于在页面中存储最后的导航历史记录
- 当用户开始与Flash互动时,标题将被完全删除,只有#tab/xx保留为标题.
- 刷新小工具时,即使出现#2之类的问题.
有人可以建议,这可能是什么问题?很有可能与sammy.js有关,因为iGoogle没有这个问题.
Could someone suggest, what the issue could be?Most probably is it related to sammy.js, as iGoogle doesn't have that issue.
推荐答案
以下变通办法是(直到现在)直到我解决问题为止的唯一方法:
The following workaround is the only way (till now) , that I got nearest to solving the issue:
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;
}
这篇关于IE标题更改为< afterHash& gt;如果网页的网址带有&#39;#&#39;,并且内嵌Flash/SWF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!