如果页面有一个带有“#”的url,并且嵌入了flash/swf,那么IE标题将改为

时间:2022-12-04 22:57:41

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.

问题是,如果IE(6.0 +),内嵌入flash内容,和页面的url #在它,当加载flash内容,或者如果用户交互,然后窗口的标题,散列后修改内容的地方。

e.g http://adobeflashwebsite.com/index.html#somediv

e。g http://adobeflashwebsite.com/index.html somediv

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.

然后,页面的标题变为“somediv”,当用户点击flash内容时,甚至是在加载flash内容时,也会多次出现。

This happens only in IE.

This below is a very specific case I was facing:

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

The following is the environment I am facing issues with:

以下是我所面临的环境问题:

  1. Shinding engine to show an iGoogle like page
  2. Shinding引擎显示一个iGoogle喜欢的页面。
  3. Sammy.js
  4. Sammy.js
  5. Gadgets rendering flash/swf
  6. 产品呈现flash / swf

The issue here is, no matter which plugin I try to embed flash with, I end up having the following problem

这里的问题是,无论我尝试使用哪个插件来嵌入flash,我最终都会遇到以下问题

  1. When the flash loads completely, it appends something like #tab/xx , which actually is a string used by sammy to store the last navigational history within the page
  2. 当flash完全加载时,它会添加诸如#tab/xx之类的内容,这实际上是sammy用来在页面中存储最后的导航历史的字符串
  3. When, a user starts interacting with the flash, then the title is completely removed and only #tab/xx remains as the title.
  4. 当用户开始与flash交互时,标题被完全删除,只有#标签/xx仍然是标题。
  5. When a gadget is refreshed, even then there is issue like #2.
  6. 当一个小工具刷新时,即使是这样,也会有第二个问题。

Could someone suggest, what the issue could be? Most probably is it related to sammy.js, as iGoogle doesn't have that issue.

有人能提出什么问题吗?很可能与萨米有关。js,因为iGoogle没有这个问题。

5 个解决方案

#1


18  

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;
    }

#2


8  

It is IE bug:

这是IE漏洞:

If you are using sammy's title method you could delay the execution a bit to make it behave on IE.

如果您正在使用sammy的title方法,您可以稍微延迟执行,使其在IE上运行。

setTimeout(function() {
    context.title('Some title');
}, 1000);

This won't solve it really, but I have noticed that a little delay helps IE sometimes.

这并不能真正解决问题,但我注意到有时稍微耽搁一下对IE有帮助。

#3


3  

I'm not really familiar with sammy.js but:

我对萨米不是很熟悉。js但是:

1) the Flash object is somehow 'taking ownership' of the title property.

1) Flash对象以某种方式“占有”标题属性。

OR

2) sammy.js is clearing the title value on HTML losing focus aka Flash gaining it (less likley and don't know why would someone do that)

2)萨米。js正在清除HTML失去焦点(Flash获得焦点)的标题值(不太可能,也不知道为什么会有人这么做)

If 1) -> define the title property in the Flash object itself (not a Flash user, dunno if it can be done easily)

如果1)->定义Flash对象本身的标题属性(不是Flash用户,如果可以轻松完成的话,dunno)

If 2) -> the javascript is dumping a variable string value connected to the title property?

如果2)-> javascript正在转储一个连接到title属性的变量字符串值?

SUGGESTION:

建议:

Enclose your flash object in a new <div> element, assigning the <div> a .click() event handler that changes the title property of a document. Try this:

将flash对象包含在一个新的

元素中,并分配
a .click()事件处理程序,该处理程序更改文档的标题属性。试试这个:

$('title').text('YourTitleHere');

#4


0  

I'm a little late to the party but I prefer this approach:

我参加聚会有点晚了,但我更喜欢这种方式:

var originalTitle = document.title;

copyLinkClipboard = new ZeroClipboard(document.getElementById('copy-link-btn'));

copyLinkClipboard.on( 'ready', function () {
  copyLinkClipboard.on( 'aftercopy', function (event) {
    event.target.blur();
    console.log('Successfully copied link to your clipboard!');
    document.title = originalTitle; // sets the title back on successful copy
  });
});

document.title = originalTitle; // sets title back when it changes on instantiation

This specifically changes the title back in the two events that ZeroClipboard changes it, rather than registering a listener on the document.onpropertychange event.

这将在ZeroClipboard更改的两个事件中修改标题,而不是在文档中注册侦听器。onpropertychange事件。

#5


0  

//some changes
if (browser.ie < 10) {
    document.attachEvent('onpropertychange', function(evt) {
        if (evt.propertyName === 'title' && document.title) {
            setTimeout(function() {
                var b=document.title.indexOf('#');
                if(b!==-1){
                    document.title = document.title.slice(0,b);
                }

            }, 1);
        }
    });
}

#1


18  

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;
    }

#2


8  

It is IE bug:

这是IE漏洞:

If you are using sammy's title method you could delay the execution a bit to make it behave on IE.

如果您正在使用sammy的title方法,您可以稍微延迟执行,使其在IE上运行。

setTimeout(function() {
    context.title('Some title');
}, 1000);

This won't solve it really, but I have noticed that a little delay helps IE sometimes.

这并不能真正解决问题,但我注意到有时稍微耽搁一下对IE有帮助。

#3


3  

I'm not really familiar with sammy.js but:

我对萨米不是很熟悉。js但是:

1) the Flash object is somehow 'taking ownership' of the title property.

1) Flash对象以某种方式“占有”标题属性。

OR

2) sammy.js is clearing the title value on HTML losing focus aka Flash gaining it (less likley and don't know why would someone do that)

2)萨米。js正在清除HTML失去焦点(Flash获得焦点)的标题值(不太可能,也不知道为什么会有人这么做)

If 1) -> define the title property in the Flash object itself (not a Flash user, dunno if it can be done easily)

如果1)->定义Flash对象本身的标题属性(不是Flash用户,如果可以轻松完成的话,dunno)

If 2) -> the javascript is dumping a variable string value connected to the title property?

如果2)-> javascript正在转储一个连接到title属性的变量字符串值?

SUGGESTION:

建议:

Enclose your flash object in a new <div> element, assigning the <div> a .click() event handler that changes the title property of a document. Try this:

将flash对象包含在一个新的

元素中,并分配
a .click()事件处理程序,该处理程序更改文档的标题属性。试试这个:

$('title').text('YourTitleHere');

#4


0  

I'm a little late to the party but I prefer this approach:

我参加聚会有点晚了,但我更喜欢这种方式:

var originalTitle = document.title;

copyLinkClipboard = new ZeroClipboard(document.getElementById('copy-link-btn'));

copyLinkClipboard.on( 'ready', function () {
  copyLinkClipboard.on( 'aftercopy', function (event) {
    event.target.blur();
    console.log('Successfully copied link to your clipboard!');
    document.title = originalTitle; // sets the title back on successful copy
  });
});

document.title = originalTitle; // sets title back when it changes on instantiation

This specifically changes the title back in the two events that ZeroClipboard changes it, rather than registering a listener on the document.onpropertychange event.

这将在ZeroClipboard更改的两个事件中修改标题,而不是在文档中注册侦听器。onpropertychange事件。

#5


0  

//some changes
if (browser.ie < 10) {
    document.attachEvent('onpropertychange', function(evt) {
        if (evt.propertyName === 'title' && document.title) {
            setTimeout(function() {
                var b=document.title.indexOf('#');
                if(b!==-1){
                    document.title = document.title.slice(0,b);
                }

            }, 1);
        }
    });
}