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.
精彩评论