views:

662

answers:

5

I can use this jQuery code to dynamically change the RSS link in the DOM in Firefox & Chrome. http://path.com/feed is normally replaced by a variable, but not for this example.

$('#rssfeed').remove();
$('head').append('<link id="rssfeed" rel="alternate" type="application/rss+xml" href="http://path.com/feed"/&gt;');

The live bookmark feature immediately updates. However, this doesn't work in IE7. In IE7 I have tried this method, also created an in the html and tried updating with .setAttribute(href,'path.com/feed'), and tried creating a new DOM element and attaching it to "<_head>" (no _ in the actual code, of course).

The only "success" I have had was doing a document.write. The big problem with this is that I can't change it after the page has loaded.

Can anyone recommend an alternate way to change the link element href and have it dynamically reloaded by IE7? Alternatively, is there a way to force the browser to re-interpret or reload the DOM without doing a full page refresh?

A: 

$('#rssfeed').attr('href, 'http://path.com/feed?id=25463456');

Setting the url with a random id means that it should not be cached, as it has never gone to that url before. And that should not affect your feed either.

geowa4
A: 

What if you use innerHTML to replace the contents of you head tag entirely (or maybe even use outerHTML on an existing link)? Not sure if it would work (and I'm on a Linux machine), but it might be worth a shot.

machineghost
A: 

In IE this might work:

document.write(document.all[0].innerHTML);

Evert
Thank you very much for this. I'm stuck on a similar problem and this helped a lot. A+ answer
SummerCodin
+2  A: 

Unfortunately, the short answers to your questions are "No" and "Sort of" because of a lack of browser support for udpating the list of feeds that are modified/added/removed in IE and Firefox.

First, in order to add elements to the document HEAD in IE (remember this applies to CSS as well), you must be sure to specify the first item in the array that is returned by jQuery's element selector (note the use of the eq(index) selector):

$('head:eq(0)').append('<link id="rssfeed" rel="alternate" type="application/rss+xml" href="http://path.com/feed" title="Path (RSS)">');

Note: I found including the TITLE attribute made it easier to see the changes.

While you can change the HREF attribute of the LINK in both IE and Firefox (through the DOM), neither will update the RSS icon menu. However, you can add LINK elements and they will be recognized by the RSS icon menu but the old entries will remain because Firefox only builds that menu when LINKs are added.

See the following links for more information:

David Lantner
A: 

Checkout quality written custom papers from professional writers

mandy campbell
Best site for quality written essays, term paper, research paper, course work, book report and resume writing.
mandy campbell
Best site for quality written essays, term paper, research paper, course work, book report and resume writing.
mandy campbell