• 0

[Javascript] Doesn't render correctly on Firefox


Question

I'm part of a world of warcraft guild, with a website hosted on guildportal.com. While trying to improve our website, i've implemented a custom rss feed that would pull the most current WoW news from mmo-champion.com to my frontpage. The script works correctly, but the problem is that on firefox, the feed gets cut off, while on IE (7 or 8) and chrome, it displays the full feed correctly.

My script is:

<div id="feed"></div>

&lt;script type="text/javascript" src="https://www.google.com/jsapi"></script>;script type="text/javascript"&gt;
google.load("feeds");
$(document).ready(function() {
var myfeeds = new Array();

var feedBox = "feed";
var tooltipWidth = 560;

var previewMode = true;
var previewLength = 80000;
var readMoreMessage = "...&lt;br&gt;&lt;br&gt;&lt;img align=right src=http://i201.photobucket.com/albums/aa236/Mottie1/testsite/styles/moreinfo.gif>;";

myfeeds.push (["MMO-Champion","http://www.mmo-champion.com/index.php?type=rss;action=.xml;board=2.0;sa=news;",1// **************************************
// Do not change anything below this line
// **************************************
var ttcss = "#dhtmltooltip";
var ttBrdr = $(ttcss).css("border-width");
var ttBkgd = $(ttcss).css("background-color");
$("#"+feedBox)
 .mouseover(function(){$(ttcss).css("border-width","0").css("background-color","transparent")})
 .mouseout (function(){$(ttcss).css("border-width",ttBrdr).css("background-color",ttBkgd)});
 for (var k = 0; k &lt; myfeeds.length; k++) {
  feedResult(myfeeds[k]);
 }
function feedResult(currentFeed) {
 var feed = new google.feeds.Feed(currentFeed[1]);
 feed.setResultFormat(google.feeds.Feed.XML_FORMAT);
 feed.setNumEntries(currentFeed[2]);
 feed.load(function(result) {
  if (!result.error) {
   var ftitle = (currentFeed[0] == "") ? (result.xmlDocument.getElementsByTagName("title")[0].firstChild.nodeValue) : (currentFeed[0]);
   var feedText = "&lt;div class='feedTitle'&gt;" + ftitle + "&lt;/div&gt;";
   var items = result.xmlDocument.getElementsByTagName("item");

   for (var j = 0; j &lt; items.length; j++) {
	var titleElement = items[j].getElementsByTagName("title")[0];
	var xtitle = titleElement.firstChild.nodeValue;

	var titleElement = items[j].getElementsByTagName("link")[0];
	try {var xlink = titleElement.firstChild.nodeValue;} catch(e) {xlink = "";}

	var titleElement = items[j].getElementsByTagName("pubDate")[0];
	try {var pubDate = titleElement.firstChild.nodeValue;} catch(e) {pubDate = "";}

	var titleElement = items[j].getElementsByTagName("description")[0];
	try {var descript = titleElement.firstChild.nodeValue;} catch(e) {descript = "";}

	pubDate = pubDate.replace(/'/g,"\'").replace(/\"/g,'\"');
   descript = descript.replace(/'/g,"\'").replace(/\"/g,'\"');

	if (previewMode) {
	 var dStart = descript.indexOf("&lt;br&gt;") + previewLength;
	 if (descript.length &gt; dStart) {descript = descript.substring(0,dStart) +  readMoreMessage;}
	}

	var feedPopup = '&lt;div&gt;&lt;table class=tooltip&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=tooltiplt&gt;';
	feedText += '&lt;div class=feedDate&gt;' + pubDate + '&lt;/div&gt;&lt;div class=feedDesc&gt;' + descript + '&lt;/div&gt;';
	feedText += '&lt;/td&gt;&lt;td class=tooltiprt&gt; &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=tooltiplb&gt; &lt;/td&gt;';
	feedText += '&lt;td class=tooltiprb&gt; &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;';


   }
   feedText += '&lt;br&gt;';
   document.getElementById(feedBox).innerHTML += feedText;
  } else { alert ("feed error from " + currentFeed[0]); }
 });
 }
});
&lt;/script&gt;

Does anyone have a clue on what it might be wrong?

My guild website is cont.guildportal.com if you want to see the script live to confirm the bug, its just below the news on the frontpage.

Thanks in advance.

Edited by Koopie

13 answers to this question

Recommended Posts

  • 0

It is not showing in Firefox because there is an error in the feed here

&lt;a target="_blank" href="http://static.mmo-champion.com/mmoc/images/news/2009/february/ulduarweap/ulduar_bow_01.jpg">;img src="https://static.mmo-champion.com/mmoc/images/news/200</div"/>;/a&gt;

that should be

&lt;a target="_blank" href="http://static.mmo-champion.com/mmoc/images/news/2009/february/ulduarweap/ulduar_bow_01.jpg">;img src="https://static.mmo-champion.com/mmoc/images/news/2009/february/ulduarweap/small/ulduar_bow_01.jpg" /&gt;
&lt;/a&gt;

Internet Explorer ignores it and carries out the rest of the presentation but Firefox stops at that point.

  • 0

Well but thats the problem, the feed does not have errors, you can check the feed code directly from the feed link. http://www.mmo-champion.com/index.php?type...rd=2.0;sa=news;

Somehow, the code above is cutting the feed on firefox but not on chrome/ie and probably not on opera too.

Edit: Made the code display 2 feed entries so the problem is more visible. As you can see, the "description" field of the rss is getting cut on firefox but not on the rest of the browsers.

Edited by Koopie
  • 0

Try this for me please.

&lt;div id="feed"&gt;&lt;/div&gt;
&lt;script type="text/javascript" src="https://www.google.com/jsapi"></script>;script type="text/javascript"&gt;

google.load("feeds");
$(document).ready(function() {
var myfeeds = "new Array()";

var feedBox = "feed";
var tooltipWidth = 560;

var previewMode = true;
var previewLength = 80000;
var readMoreMessage = "...&lt;br&gt;&lt;br&gt;&lt;img align=right src=http://i201.photobucket.com/albums/aa236/Mottie1/testsite/styles/moreinfo.gif>;";

myfeeds.push (["MMO-Champion","http://www.mmo-champion.com/index.php?type=rss;action=.xml;board=2.0;sa=news;",1// **************************************
// Do not change anything below this line
// **************************************
var ttcss = "#dhtmltooltip";
var ttBrdr = $(ttcss).css("border-width");
var ttBkgd = $(ttcss).css("background-color");
$("#"+feedBox);
.mouseover(function(){$(ttcss).css("border-width","0").css("background-color","transparent")});
.mouseout (function(){$(ttcss).css("border-width",ttBrdr).css("background-color",ttBkgd)});
function feedResult(currentFeed) {
var feed = new google.feeds.Feed(currentFeed[1]);
feed.setResultFormat(google.feeds.Feed.XML_FORMAT);
feed.setNumEntries(currentFeed[2]);
feed.load(function(result) {
  if (!result.error) {
   var ftitle = (currentFeed[0] == "") ? (result.xmlDocument.getElementsByTagName("title")[0].firstChild.nodeValue) : (currentFeed[0]);
   var feedText = "&lt;div class='feedTitle'&gt;" + ftitle + "&lt;/div&gt;";
   var items = result.xmlDocument.getElementsByTagName("item");

   for (var j = 0; j &lt; items.length; j++) {
	var titleElement = items[j].getElementsByTagName("title")[0];
	var xtitle = titleElement.firstChild.nodeValue;

	var titleElement = items[j].getElementsByTagName("link")[0];
	try {var xlink = titleElement.firstChild.nodeValue;} catch(e) {xlink = "";}

	var titleElement = items[j].getElementsByTagName("pubDate")[0];
	try {var pubDate = titleElement.firstChild.nodeValue;} catch(e) {pubDate = "";}

	var titleElement = items[j].getElementsByTagName("description")[0];
	try {var descript = titleElement.firstChild.nodeValue;} catch(e) {descript = "";}

	pubDate = pubDate.replace(/'/g,"\'").replace(/\"/g,'\"');
   descript = descript.replace(/'/g,"\'").replace(/\"/g,'\"');

	if (previewMode) {
	 var dStart = descript.indexOf("&lt;br&gt;") + previewLength;
	 if (descript.length &gt; dStart) {descript = descript.substring(0,dStart) +  readMoreMessage;}
	}
for (var k = 0; k &lt; myfeeds.length; k++) {
  feedResult(myfeeds[k]);
}
	var feedPopup = '&lt;div&gt;&lt;table class=tooltip&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class=tooltiplt&gt;';
	feedText += '&lt;div class=feedDate&gt;' + pubDate + '&lt;/div&gt;&lt;div class=feedDesc&gt;' + descript + '&lt;/div&gt;';
	feedText += '&lt;/td&gt;&lt;td class=tooltiprt&gt; &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=tooltiplb&gt; &lt;/td&gt;';
	feedText += '&lt;td class=tooltiprb&gt; &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;';


   }

   feedText += '&lt;br&gt;';
   document.getElementById(feedBox).innerHTML += feedText;
  } else { alert ("feed error from " + currentFeed[0]); }
});
}
});

&lt;/script&gt;

  • 0

The feed doesn't load with that code. I did noticed you added a couple of ; and changed the array part and also deleted a few stuff, tried to revert things one by one and it did not loaded. I'm currently clueless why this problem happens. Appreciate your help karma.

  • 0

Try change this:

feed.load(function(result) {
  if (!result.error) {
   var ftitle = (currentFeed[0] == "") ? (result.xmlDocument.getElementsByTagName("title")[0].firstChild.nodeValue) : (currentFeed[0]);
   var feedText = "&lt;div class='feedTitle'&gt;" + ftitle + "&lt;/div&gt;";
   var items = result.xmlDocument.getElementsByTagName("item");

to this:

feed.load(function(result) {
  if (!result.error) {
   result.xmlDocument.normalize();
   var ftitle = (currentFeed[0] == "") ? (result.xmlDocument.getElementsByTagName("title")[0].firstChild.nodeValue) : (currentFeed[0]);
   var feedText = "&lt;div class='feedTitle'&gt;" + ftitle + "&lt;/div&gt;";
   var items = result.xmlDocument.getElementsByTagName("item");

It's hard for me to test because of all the linked Javascript files

  • 0
  Banjo said:
Try change this:
feed.load(function(result) {
   if (!result.error) {
	var ftitle = (currentFeed[0] == "") ? (result.xmlDocument.getElementsByTagName("title")[0].firstChild.nodeValue) : (currentFeed[0]);
	var feedText = "&lt;div class='feedTitle'&gt;" + ftitle + "&lt;/div&gt;";
	var items = result.xmlDocument.getElementsByTagName("item");

to this:

feed.load(function(result) {
   if (!result.error) {
	result.xmlDocument.normalize();
	var ftitle = (currentFeed[0] == "") ? (result.xmlDocument.getElementsByTagName("title")[0].firstChild.nodeValue) : (currentFeed[0]);
	var feedText = "&lt;div class='feedTitle'&gt;" + ftitle + "&lt;/div&gt;";
	var items = result.xmlDocument.getElementsByTagName("item");

It's hard for me to test because of all the linked Javascript files

This did the trick, however, only on firefox. With the "result.xmlDocument.normalize();", the feed does not load on IE.

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)
Timestamp: Tue, 3 Mar 2009 15:53:07 UTC


Message: Object doesn't support this property or method
Line: 685
Char: 4
Code: 0
URI: http://cont.guildportal.com/Guild.aspx?GuildID=51848&TabID=453954

Line 685 is the "result.xmlDocument.normalize();"

Just arrived home, so will try to make the blank page with the feed javascript only so its easier.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • https://www.neowin.net/news/tags/mastodon/ In short: Federated Twitter (X)
    • Keep in mind it was purchased by an advertising company. I use SearxNG.
    • I am using Waterfox Private Search now that I started using the Waterfox browser on my PC and Android. Both work great* search waterfox net with full stops in between. * I have an issue where making comments on articles on various websites is difficult with Waterfox on Android as it randomly adds spaces and doubles up on text.
    • I can't believe it was only two years since the last time MS raised their prices and now they think they can do it again so soon. Of course they needed to backtrack on this. I hope Nintendo is next.
    • I guess I gotta be even more specific then since I'm looking for an absolute confirmation.  The mini PC has never booted up or powered on by me. I'm assuming it'll be like buying a new PC from a store. Nothing is set up. Like absolutely nothing on the mini PC because I can't emphasize this enough. My USB drive already has Windows set up on it from my other desktop so I know it's clean. So now I connect it to the mini PC before it's even booted up or go to the desktop. I then turn on the mini PC and boot into the USB drive. I should see an existing partition. I'll delete it and then install Windows again over the entire drive. I don't necessarily want to create a separate partition. Once it installs and boots to the desktop, I'm assuming the drive is "clean" and free of any malware/viruses. Basically, this process will eliminate any potential for malware/viruses to still somehow hide in the SSD and then potentially affect me later.  I'm being very anal about this because I really don't trust anything bought from AliExpress, but the price was very tempting.  Is Windows Defender reliable? Afterwards, if I do a full scan and it doesn't find anything in the SSD and the USB drive, can I be confident the mini PC is now safe and secured to enter my banking credentials? If not, what else can I do to be absolutely certain?
  • Recent Achievements

    • Collaborator
      fernan99 earned a badge
      Collaborator
    • Collaborator
      MikeK13 earned a badge
      Collaborator
    • One Month Later
      Alexander 001 earned a badge
      One Month Later
    • One Month Later
      Antonio Barboza earned a badge
      One Month Later
    • Week One Done
      Antonio Barboza earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      584
    2. 2
      ATLien_0
      219
    3. 3
      Michael Scrip
      170
    4. 4
      Xenon
      136
    5. 5
      +FloatingFatMan
      123
  • Tell a friend

    Love Neowin? Tell a friend!