开发者

problem (IE8) inserting 'alternate rss link ' in "head" section fails. (Succeeds in Firefox 3.5)

开发者 https://www.devze.com 2022-12-16 20:41 出处:网络
We wish to use jquery/javascript to add \'alternate link rss\' elements in thesection of a resulting html document, i.e. so the orange \'rss\' icon shows up on the right side of the browser\'s url-bar

We wish to use jquery/javascript to add 'alternate link rss' elements in the section of a resulting html document, i.e. so the orange 'rss' icon shows up on the right side of the browser's url-bar (aka "awesome bar" in FF)

Such an approach simplifies adding the 'subscribe' links in the section. Each chunk of the page could add rss link(s) as needed in a single pass, rather than requiring two passes, one to gather the 'rss links', and another to render the page

Here's what I found:

I added this code to a test page (in a script block)

$( 
function() 
{
("<link rel='alternate' type='application/rss+xml' href='/path/to/another/rss'>").insertAfter("meta")
}

)

  • It works in Firefox (version 3.5开发者_开发百科)

  • It fails in IE8

  • When it fails in IE8, it actually breaks any existing rss links. For example if the page's head section already had these links:

  • After the javascript executes, IE8 grays out the 'orange' RSS button. (FF3.5, in contrast displays all three links correctly)

  • I've tried a few other variants but with no success in IE8

Is this approach kosher? Do well-behaved browsers adjust their 'head' section on the fly as part of DOM manipulation? Any comments or insights?

thanks,

bill


Try:

$("head").append("<link rel='alternate' type='application/rss+xml' href='/path/to/another/rss'>");

Should work as expected.

0

精彩评论

暂无评论...
验证码 换一张
取 消