How to get the file using it's URL in Javascript?

How to get the RSS URL in javascript?

  • How do I access the RSS URL defined in the tag of a page, using javascript? I want to use a bookmarklet to capture the RSS URL of the page I'm looking at. I'm sure there must be a document.something property that I could access, but I don't know enough javascript to figure it out.

  • Answer:

teaperson at Ask.Metafilter.Com Visit the source

Was this solution helpful to you?

Other answers

The bookmarklet was stripped by Mefi's XSS filtering - I figured that would happen. Visit Laughing Meme for the unfiltered bookmarklet.

slhack3r

I wrote one that turns out to be nearly the same as the previous answer, but I don't want it to be for naught:javascript:var links = document.getElementsByTagName('link'); for (var i = 0; links[i] && links[i].getAttribute('type') != 'application/rss+xml'; ++i); if (links[i] && links[i].hasAttribute('href')) alert(links[i].getAttribute('href'));

moift

This one will alert for all if there are multiples instead of just the firstjavascript:var links = document.getElementsByTagName('link'); for (var i = 0; links[i]; ++i) { if (links[i].getAttribute('type') == 'application/rss+xml' && links[i].hasAttribute('href')) alert(links[i].getAttribute('href')); }

moift

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.