views:

112

answers:

1

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

+1  A: 

Try:

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

Should work as expected.

Olivier Tille
I just tried your suggestion. It does not work, i.e. same problem.
did work for me in IE8
Olivier Tille
http://www.imagebam.com/image/813b7464563463
Olivier Tille
Olivier, It looks like IE8 rendered the DOM correctly . However in your image it still shows the 'rss icon' as 'grayed out'. It should be 'orange' and 'clickable'.(The RSS icon is on the right side of the browser, between the 'house' and 'email' icons' )
hm... right. sorry didn't see that.
Olivier Tille