IE title changes to if the page has a url with '#' , and has flash/swf embedded in it

后端 未结 5 794

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

相关标签:
5条回答
  • 2021-01-31 10:21

    It is IE bug:

    • http://bugs.adobe.com/jira/browse/FP-240 (includes couple of workarounds)
    • http://www.mail-archive.com/discuss@jquery.com/msg14509.html
    • http://code.google.com/p/swfobject/issues/detail?id=293

    If you are using sammy's title method you could delay the execution a bit to make it behave on 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.

    0 讨论(0)
  • 2021-01-31 10:22

    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.

    0 讨论(0)
  • 2021-01-31 10:31

    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;
        }
    
    0 讨论(0)
  • 2021-01-31 10:31

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

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

    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)

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

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

    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:

    $('title').text('YourTitleHere');
    
    0 讨论(0)
  • 2021-01-31 10:39
    //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);
            }
        });
    }
    
    0 讨论(0)
提交回复
热议问题