RSS feeds

T

Trevor L.

Following some earleir advice , i set u an RSS feed on my website.

However, it only works inIE6, not Firefox1.5

Placing alerts in the code tells me that the test
"if(window.ActiveXObject)" returns false in Firefox

Questions
1. How do I turn on ActiveX objects in Firefox?
Or if I can't
2 .How can I modify the code to work in Firefox ?

The code follows below.

Another alerts tell me that this code does not execute in Firefox
xmlDoc.load(URI)

==========
<html>
<!-- rss-reader.html -->
<head>

<script type="text/javascript">
//-------------------
function readRSS(URI)
{
//----Internal function --------
function formatRSS()
{
var item = items.getElementsByTagName('item')
var items_count = item.length
var pubDate = new Array(),
date = new Array(),
link = new Array(),
title = new Array(),
description = new Array(),
guid = new Array()

for(var i = 0; i < items_count; i++)
{
if(item.getElementsByTagName('pubDate').length==1)
pubDate=item.getElementsByTagName('pubDate')[0]

if(item.getElementsByTagName('dc:date').length==1)
date = item.getElementsByTagName('dc:date')[0]

if(item.getElementsByTagName('link').length==1)
link = item.getElementsByTagName('link')[0]

if(item.getElementsByTagName('guid').length==1)
guid = item.getElementsByTagName('guid')[0]

if(item.getElementsByTagName('title').length==1)
title = item.getElementsByTagName('title')[0]

if(item.getElementsByTagName('description').length==1)
description = item.getElementsByTagName('description')[0]
}

if((description.length==0) && (title.length==0))
return false

document.write('<html><head><title>' +
xmlDoc.getElementsByTagName('title')[0].firstChild.nodeValue
+ '</title></head><body>')
document.write('<span style="font-family:verdana,arial,helvetica;
font-size:8pt">')
document.write('<center><a href="index_main.html"><h3>[Go
Back]</h3></a></center>')
document.write('<center><a href="' +
xmlDoc.getElementsByTagName('link')[0].firstChild.nodeValue + '"><h2>'
+
xmlDoc.getElementsByTagName('description')[0].firstChild.nodeValue
+ '</h2></a></center>')

var ws = /\S/
for(var i = 0; i < items_count; i++)
{
var pubDate_w, title_w, link_w

pubDate_w = (pubDate.length>0) ? pubDate.firstChild.nodeValue :
"<i>Date NA</i>"
if(document.all)
title_w = (title.length > 0) ? title.text : "<i>Untitled</i>"
else
title_w = (title.length > 0) ? title.firstChild.nodeValue :
"<i>Untitled</i>"

link_w = (link.length > 0) ? link.firstChild.nodeValue : ""
if(link.length == 0)
link_w = (guid.length > 0) ? guid.firstChild.nodeValue : ""

if(title.length > 0)
title_w = (!ws.test(title_w)) ? "<i>Untitled</i>" : title_w

if(pubDate.length == 0)
pubDate_w = (date.length > 0) ? date.firstChild.nodeValue : "<i>Date
NA</i>"

document.write('<a href="' + link_w + '"><b>' + title_w + '</b></a> <b>['
+ pubDate_w + ']</b><br>')
if(description.length > 0)
document.write('<font size="-1">' + description.firstChild.nodeValue
+ '</font><hr noshade><br>')
}
document.write('</span></body></html>')
}
//-------------------------------

if(window.ActiveXObject)
{ alert ('window.ActiveXObject')
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async = false
while(xmlDoc.readyState != 4)
document.write('Loading...')
}
else
{ alert ('Not window.ActiveXObject')
if(document.implementation && document.implementation.createDocument)
xmlDoc = document.implementation.createDocument("","doc",null) }

alert ('xmlDoc.load starting')
xmlDoc.load(URI)
alert ('xmlDoc.load complete')
items = xmlDoc // global - passed to formatRSS

alert ('typeof(xmlDoc) = ' + typeof(xmlDoc))
if(typeof(xmlDoc) != "undefined")
{
if(window.ActiveXObject)
formatRSS()
else
xmlDoc.onload = formatRSS
}
}
//-------------------

function checkString()
{
var loc = document.location.href.split("?")
if(loc.length > 1)
{
URI = loc[1].split("=")
if(URI.length > 1)
{
var retURI=""
for(var i = 1; i < URI.length; i++)
retURI += URI
try {readRSS(unescape(retURI)) }
catch(e) {}
}
}
}
//-------------------
</script>
</head>
<body onload="checkString();">

<table><tr><td>
<h1>JavaScript RSS Reader</h1>

<form id="form1" name="form1" method="get" action="rss-reader.html">
<b>RSS URL: </b>
<input type="text" id="URI" name="URI" value="http://" />
<input type="submit" value="Read RSS" />
</form>

</td></tr></table>
</body>
 
S

Stefan B Rusynko

Scrap the JavaScript and activeX
See http://msdn.microsoft.com/library/d...c_fp2003_ta/html/OfficeFrontPageCreateRSS.asp

PS
- you may have problems due to your frames

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| Following some earleir advice , i set u an RSS feed on my website.
|
| However, it only works inIE6, not Firefox1.5
|
| Placing alerts in the code tells me that the test
| "if(window.ActiveXObject)" returns false in Firefox
|
| Questions
| 1. How do I turn on ActiveX objects in Firefox?
| Or if I can't
| 2 .How can I modify the code to work in Firefox ?
|
| The code follows below.
|
| Another alerts tell me that this code does not execute in Firefox
| xmlDoc.load(URI)
|
| ==========
| <html>
| <!-- rss-reader.html -->
| <head>
|
| <script type="text/javascript">
| //-------------------
| function readRSS(URI)
| {
| //----Internal function --------
| function formatRSS()
| {
| var item = items.getElementsByTagName('item')
| var items_count = item.length
| var pubDate = new Array(),
| date = new Array(),
| link = new Array(),
| title = new Array(),
| description = new Array(),
| guid = new Array()
|
| for(var i = 0; i < items_count; i++)
| {
| if(item.getElementsByTagName('pubDate').length==1)
| pubDate=item.getElementsByTagName('pubDate')[0]
|
| if(item.getElementsByTagName('dc:date').length==1)
| date = item.getElementsByTagName('dc:date')[0]
|
| if(item.getElementsByTagName('link').length==1)
| link = item.getElementsByTagName('link')[0]
|
| if(item.getElementsByTagName('guid').length==1)
| guid = item.getElementsByTagName('guid')[0]
|
| if(item.getElementsByTagName('title').length==1)
| title = item.getElementsByTagName('title')[0]
|
| if(item.getElementsByTagName('description').length==1)
| description = item.getElementsByTagName('description')[0]
| }
|
| if((description.length==0) && (title.length==0))
| return false
|
| document.write('<html><head><title>' +
| xmlDoc.getElementsByTagName('title')[0].firstChild.nodeValue
| + '</title></head><body>')
| document.write('<span style="font-family:verdana,arial,helvetica;
| font-size:8pt">')
| document.write('<center><a href="index_main.html"><h3>[Go
| Back]</h3></a></center>')
| document.write('<center><a href="' +
| xmlDoc.getElementsByTagName('link')[0].firstChild.nodeValue + '"><h2>'
| +
| xmlDoc.getElementsByTagName('description')[0].firstChild.nodeValue
| + '</h2></a></center>')
|
| var ws = /\S/
| for(var i = 0; i < items_count; i++)
| {
| var pubDate_w, title_w, link_w
|
| pubDate_w = (pubDate.length>0) ? pubDate.firstChild.nodeValue :
| "<i>Date NA</i>"
| if(document.all)
| title_w = (title.length > 0) ? title.text : "<i>Untitled</i>"
| else
| title_w = (title.length > 0) ? title.firstChild.nodeValue :
| "<i>Untitled</i>"
|
| link_w = (link.length > 0) ? link.firstChild.nodeValue : ""
| if(link.length == 0)
| link_w = (guid.length > 0) ? guid.firstChild.nodeValue : ""
|
| if(title.length > 0)
| title_w = (!ws.test(title_w)) ? "<i>Untitled</i>" : title_w
|
| if(pubDate.length == 0)
| pubDate_w = (date.length > 0) ? date.firstChild.nodeValue : "<i>Date
| NA</i>"
|
| document.write('<a href="' + link_w + '"><b>' + title_w + '</b></a> <b>['
| + pubDate_w + ']</b><br>')
| if(description.length > 0)
| document.write('<font size="-1">' + description.firstChild.nodeValue
| + '</font><hr noshade><br>')
| }
| document.write('</span></body></html>')
| }
| //-------------------------------
|
| if(window.ActiveXObject)
| { alert ('window.ActiveXObject')
| var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
| xmlDoc.async = false
| while(xmlDoc.readyState != 4)
| document.write('Loading...')
| }
| else
| { alert ('Not window.ActiveXObject')
| if(document.implementation && document.implementation.createDocument)
| xmlDoc = document.implementation.createDocument("","doc",null) }
|
| alert ('xmlDoc.load starting')
| xmlDoc.load(URI)
| alert ('xmlDoc.load complete')
| items = xmlDoc // global - passed to formatRSS
|
| alert ('typeof(xmlDoc) = ' + typeof(xmlDoc))
| if(typeof(xmlDoc) != "undefined")
| {
| if(window.ActiveXObject)
| formatRSS()
| else
| xmlDoc.onload = formatRSS
| }
| }
| //-------------------
|
| function checkString()
| {
| var loc = document.location.href.split("?")
| if(loc.length > 1)
| {
| URI = loc[1].split("=")
| if(URI.length > 1)
| {
| var retURI=""
| for(var i = 1; i < URI.length; i++)
| retURI += URI
| try {readRSS(unescape(retURI)) }
| catch(e) {}
| }
| }
| }
| //-------------------
| </script>
| </head>
| <body onload="checkString();">
|
| <table><tr><td>
| <h1>JavaScript RSS Reader</h1>
|
| <form id="form1" name="form1" method="get" action="rss-reader.html">
| <b>RSS URL: </b>
| <input type="text" id="URI" name="URI" value="http://" />
| <input type="submit" value="Read RSS" />
| </form>
|
| </td></tr></table>
| </body>
|
| --
| Cheers,
| Trevor L.
| Website: http://tandcl.homemail.com.au
|
|
 
T

Trevor L.

Stefan said:
Scrap the JavaScript and activeX
See
http://msdn.microsoft.com/library/d...c_fp2003_ta/html/OfficeFrontPageCreateRSS.asp

PS
- you may have problems due to your frames

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________

This looks far too complex, using VBA etc. I don't even know whether it will
display the RSS in a frame which is what the Javascript does (in IE6)

In trying to debug the code, I find that Firefox objects to this code
if(window.ActiveXObject)
{ alert ('window.ActiveXObject')
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async = false
while(xmlDoc.readyState != 4)
document.write('Loading...')
}
else
{ alert ('Not window.ActiveXObject')
if(document.implementation && document.implementation.createDocument)
xmlDoc = document.implementation.createDocument("","doc",null)
alert ('xmlDoc=' + xmlDoc )} }

alert ('xmlDoc.load starting')
xmlDoc.load(URI)
alert ('xmlDoc.load complete')
items = xmlDoc // global - passed to formatRSS

alert ('typeof(xmlDoc) = ' + typeof(xmlDoc))
if(typeof(xmlDoc) != "undefined")
{
if(window.ActiveXObject)
formatRSS()
else
xmlDoc.onload = formatRSS
}

It goes to the else path of "if(window.ActiveXObject)", i.e. "alert ('Not
window.ActiveXObject')" displays
It executes "xmlDoc= ........." and the alert shows xmlDoc is
[objectXMLDocument]
The alert "alert ('xmlDoc.load starting')" does display
The alert "alert ('xmlDoc.load complete')" does *not* display

There must be a simple solution and an answer to these questions:
What does the statement "xmlDoc.load(URI)" do?
Why does it fail in Firefox?
What is missing from Firefox?

Because the line xmlDoc.load fails, I can't test any further, e.g. I don't
know whether xmlDoc.onload = formatRSS would execute

Alternatively, I have found another site which retrieves a RSS feed by use
of this script
<script type="text/javascript"
src="http://p3k.org/rss/?url=http://abc....mpact=&amp;showXmlButton=&amp;javascript=true">
</script>

How can I write some HTML code which will call this with an onclick?
(The result is a series of document.writeln() commands i.e. it is
javascript.)

This should also be easy, but my mind has gone blank right now. I will have
to ease the stress by going out for while
 
T

Thomas A. Rowe

FYI: ActiveX is only supported in IE Browsers and can be disabled.

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
==============================================
If you feel your current issue is a results of installing
a Service Pack or security update, please contact
Microsoft Product Support Services:
http://support.microsoft.com
If the problem can be shown to have been caused by a
security update, then there is usually no charge for the call.
==============================================

Trevor L. said:
Stefan said:
Scrap the JavaScript and activeX
See
http://msdn.microsoft.com/library/d...c_fp2003_ta/html/OfficeFrontPageCreateRSS.asp

PS
- you may have problems due to your frames

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________

This looks far too complex, using VBA etc. I don't even know whether it will display the RSS in a
frame which is what the Javascript does (in IE6)

In trying to debug the code, I find that Firefox objects to this code
if(window.ActiveXObject)
{ alert ('window.ActiveXObject')
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async = false
while(xmlDoc.readyState != 4)
document.write('Loading...')
}
else
{ alert ('Not window.ActiveXObject')
if(document.implementation && document.implementation.createDocument)
xmlDoc = document.implementation.createDocument("","doc",null)
alert ('xmlDoc=' + xmlDoc )} }

alert ('xmlDoc.load starting')
xmlDoc.load(URI)
alert ('xmlDoc.load complete')
items = xmlDoc // global - passed to formatRSS

alert ('typeof(xmlDoc) = ' + typeof(xmlDoc))
if(typeof(xmlDoc) != "undefined")
{
if(window.ActiveXObject)
formatRSS()
else
xmlDoc.onload = formatRSS
}

It goes to the else path of "if(window.ActiveXObject)", i.e. "alert ('Not window.ActiveXObject')"
displays
It executes "xmlDoc= ........." and the alert shows xmlDoc is [objectXMLDocument]
The alert "alert ('xmlDoc.load starting')" does display
The alert "alert ('xmlDoc.load complete')" does *not* display

There must be a simple solution and an answer to these questions:
What does the statement "xmlDoc.load(URI)" do?
Why does it fail in Firefox?
What is missing from Firefox?

Because the line xmlDoc.load fails, I can't test any further, e.g. I don't know whether
xmlDoc.onload = formatRSS would execute

Alternatively, I have found another site which retrieves a RSS feed by use of this script
<script type="text/javascript"

src="http://p3k.org/rss/?url=http://abc....mpact=&amp;showXmlButton=&amp;javascript=true">
</script>

How can I write some HTML code which will call this with an onclick?
(The result is a series of document.writeln() commands i.e. it is javascript.)

This should also be easy, but my mind has gone blank right now. I will have to ease the stress by
going out for while
 
T

Trevor L.

Thomas said:
FYI: ActiveX is only supported in IE Browsers and can be disabled.

Thanks, Thomas
Another example of IE doing its own thing ??

Therefore I have to give up on using ActiveX in Firefox.

I wonder why the else paths in the code I posted doesn't work.
In light of the fact that ActiveX only works in IE, it must have been put
there to cater for such browsers. And yet, Firefox, which I thought
conformed to the standards isn't one in which it works. Strange!
 
W

Windsun

You can get an activex plugin for FF, but few people do. And, a lot have it
turned off in IE. Activex is never a good idea on websites. Activex has
nothing to do with website standards.

-------------------------------------------------------------------------
 
T

Trevor L.

Windsun said:
You can get an activex plugin for FF, but few people do. And, a lot
have it turned off in IE. Activex is never a good idea on websites.
Activex has nothing to do with website standards.

Thanks, Windsun

I am happy to avoid ActiveX.

I wasn't trying to say that Firefox should use ActiveX because this conforms
to website standards.

What I was trying to say was that I assumed that the code (which I acquired
from a website) was set up to cater for browsers with ActiveX (IE6) and
those without (Firefox and probably many others)

I therefore assumed that the path through the code when ActiveX is not
applicable should cater for browsers which conform to the standards. But I
found that this code failed in Firefox.

So my questions were (or at least *now* are):

Why does the code not work in Firefox?
Is the code not valid for Firefox?
If so, did the coder do something wrong?
Did the coder use code that Firefox can read?
What changes can be made to the code so that Firefox can read it?

BTW,
I have found a website which can render RSS feeds in Firefox OK. It is not
quite as good as the code I was using (eg Date is not displayed), but it is
good enough.

Although I can use this website, I would still like to get some answers to
my questions so that I have other options.

Thanks to all who have contributed (or are yet to contribute)
 
T

Thomas A. Rowe

Have you contacted the author of your script to make sure the it was written to handle version of FF
you are running?

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
==============================================
If you feel your current issue is a results of installing
a Service Pack or security update, please contact
Microsoft Product Support Services:
http://support.microsoft.com
If the problem can be shown to have been caused by a
security update, then there is usually no charge for the call.
==============================================
 
W

Windsun

Hmm.. the code for getting RSS feeds is pretty simple, and should really
have nothing to do with ActiveX or anything else. All it does is pick up the
feeds and insert them into an HTML file basically. I forgot what we use, but
it was just a cut and paste freebie thing for RSS 2.0. It would seem that
any problems would not be with the RSS part.

-------------------------------------------------------------------------
 
T

Trevor L.

Thomas said:
Have you contacted the author of your script to make sure the it was
written to handle version of FF you are running?

Thanks for the idea, but in all my searching for some good code, I forget where it came from. The author doesn't have his name in the heading - either that or I deleted it (I think not).

I would like to be able to adapt it to Firefox, because there seems to be more control over the formatting. I'll have to rack my brains as to where I found it - by googling for something like "Javascript code for RSS feeds".

However, I since found two other reasonably good ones:

<script type="text/javascript"
src="http://p3k.org/rss/?url=http://abc.net.au/news/syndicate/topstoriesrss.xml
&amp;align=left&amp;width=800&amp;frameColor=white&amp;titleBarColor=lightblue&amp;titleBarTextColor=black&amp;boxFillColor=silver&amp;textColor=black&amp;fontFace=&amp;maxItems=30&amp;compact=&amp;showXmlButton=&amp;javascript=true">
</script>
This one is adaptable in that the parameters supplied can be changed, e.g. I changed the "silver" spec and maxitems (to 30).

<script type="text/javascript"
src="http://rssxpress.ukoln.ac.uk/lite/viewer/?rss=http://abc.net.au/news/syndicate/topstoriesrss.xml">
</script>

This one allows you to override the CSS used - 7 named styles are given which can be changed as needed

In each case, all one has to do is paste in the first parameter (or only paramter for the second one)
 
T

Trevor L.

Windsun said:
Hmm.. the code for getting RSS feeds is pretty simple, and should
really have nothing to do with ActiveX or anything else. All it does
is pick up the feeds and insert them into an HTML file basically. I
forgot what we use, but it was just a cut and paste freebie thing for
RSS 2.0. It would seem that any problems would not be with the RSS
part.

I have just posted two simple lines of code that I found.
These connect to another website, accept your RSS feed's url, and presents
it back as formatted HTML.

Is yours like these ?

The reason I liked the other code was that it appeared to offer more control
over the formatting. And I was quite happy to do without ActiveX.

No, I did not at any time suspect that the problem was with the RSS side.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top