Firefox Javascript Help!! :(

J

Joseph

Hello everyone,

I'm trying to build a page that utilizes google calendar data to build
dynamic content, but for some reason i cannot get Firefox to display
information via the innerHTML property. I know for sure that the data
is coming through and it is being formatted using my coding, but for
some reason when it goes to apply the informaiton to the innerHTML
property of the div tag it doesn't get applied.

Strangely enough, it works fine for IE. I read up on the net that
Firefox supports the innerHTML property, so i'm completely confused.

Can someone please help me out?

here is a copy of the coding

<code>
var startItem = "<div id='rss_item'>";
var startTitle = "<h2 id='rss_title'>";
var startImage = "<img id='rss_image' src=\"";
var startDescription = "<p id='rss_description'>";
var startLink = "<a target='_blank' class='rss_link' href='";

var endImage = "\" onError=\"erroredImage(this)\">";
var endTitle = "</h2>";
var endDescription = "</p>";
var endLink = "'>View More Details</a>";
var endTag = "</div>";
var item_html = "";

if (RSS.items.length<=0)
rssDiv.innerHTML = noItemsMessage
else
{
for (var i=0; i<RSS.items.length; i++)
{
if (RSS.items.title!=null)
{
item_html = startItem; //begin item listing
item_html += (RSS.items.title == null) ? "" : startTitle +
RSS.items.title + endTitle;
item_html += (RSS.items.image == null) ? "" : startImage +
RSS.items.image + endImage;
item_html += (RSS.items.pubDate == null) ? "" :
RSS.items.pubDate;
item_html += (RSS.items.description == null) ? "" :
startDescription + RSS.items.description + endDescription;
item_html += (RSS.items.link == null) ? "" : startLink +
RSS.items.link + endLink;

item_html += endTag;
}

rssDiv.innerHTML += item_html;
}
}

return true;
</code>
 
A

Andrew Bailey

Joseph said:
Hello everyone,

I'm trying to build a page that utilizes google calendar data to build
dynamic content, but for some reason i cannot get Firefox to display
information via the innerHTML property. I know for sure that the data
is coming through and it is being formatted using my coding, but for
some reason when it goes to apply the informaiton to the innerHTML
property of the div tag it doesn't get applied.

Strangely enough, it works fine for IE. I read up on the net that
Firefox supports the innerHTML property, so i'm completely confused.

Can someone please help me out?

here is a copy of the coding

<code>
var startItem = "<div id='rss_item'>";
var startTitle = "<h2 id='rss_title'>";
var startImage = "<img id='rss_image' src=\"";
var startDescription = "<p id='rss_description'>";
var startLink = "<a target='_blank' class='rss_link' href='";

var endImage = "\" onError=\"erroredImage(this)\">";
var endTitle = "</h2>";
var endDescription = "</p>";
var endLink = "'>View More Details</a>";
var endTag = "</div>";
var item_html = "";

if (RSS.items.length<=0)
rssDiv.innerHTML = noItemsMessage
else
{
for (var i=0; i<RSS.items.length; i++)
{
if (RSS.items.title!=null)
{
item_html = startItem; //begin item listing
item_html += (RSS.items.title == null) ? "" : startTitle +
RSS.items.title + endTitle;
item_html += (RSS.items.image == null) ? "" : startImage +
RSS.items.image + endImage;
item_html += (RSS.items.pubDate == null) ? "" :
RSS.items.pubDate;
item_html += (RSS.items.description == null) ? "" :
startDescription + RSS.items.description + endDescription;
item_html += (RSS.items.link == null) ? "" : startLink +
RSS.items.link + endLink;

item_html += endTag;
}

rssDiv.innerHTML += item_html;
}
}

return true;
</code>


Hi,

Try replacing...

rssDiv.innerHTML += item_html;

....with...

document.getElementById('rssDiv').innerHTML += item_html;

.... and make sure your div has the correct ID like...

<div id="rssDiv">content</div>


Hope this helps

Andy
 
J

Joseph

Thanx I'll try that, but i forgot to explain that i'm not referencing
rssDiv as its own element, i'm referencing the element passed through
another argument in to the variable rssDiv. Does that make a
difference?
 
G

GArlington

Thanx I'll try that, but i forgot to explain that i'm not referencing
rssDiv as its own element, i'm referencing the element passed through
another argument in to the variable rssDiv. Does that make a
difference?

Not as long as you obtain object reference the correct way - i.e. use
document.getElementById() in the function that passes the reference to
this one...
 
J

Joseph

it does

here is the first part of the code. rssDiv is a global variable and
srcDiv is a text string representing the div name. For some reason it
doesn't want to programatically change innerHTML :( Any other ideas?

<code>
var rssDiv

function loadRSS(rssfile, srcDiv)
{

rssDiv = document.getElementById(srcDiv)
if(rssDiv==undefined)
return false;

//dimension the AJAX
if (window.ActiveXObject) //IE
xhr = new ActiveXObject("Microsoft.XMLHTTP");
else if (window.XMLHttpRequest) //other
xhr = new XMLHttpRequest();
else
{
rssDiv.innerHTML="Your browser does not support RSS"; //
cancel request
return false;
}

...... </code>
 
P

pr

Joseph said:
it does

here is the first part of the code. rssDiv is a global variable and
srcDiv is a text string representing the div name. For some reason it
doesn't want to programatically change innerHTML :( Any other ideas?
[...]

This could go on forever unless you can supply a URL or (worst case) a
small but complete example, including representative XML. You haven't
yet indicated how your 'RSS' object is defined and what RSS.items[n] may
be expected to contain. Since mocking up an 'RSS' object of my own
yields perfectly sensible-looking results using the code you have so far
posted, it seems that the problem lies with something we haven't seen yet.

BTW you did *look* in the error console for an explanatory message
didn't you?
 
J

Joseph

Joseph said:
here is the first part of the code. rssDiv is a global variable and
srcDiv is a text string representing the div name. For some reason it
doesn't want to programatically change innerHTML :( Any other ideas?

[...]

This could go on forever unless you can supply a URL or (worst case) a
small but complete example, including representative XML. You haven't
yet indicated how your 'RSS' object is defined and what RSS.items[n] may
be expected to contain. Since mocking up an 'RSS' object of my own
yields perfectly sensible-looking results using the code you have so far
posted, it seems that the problem lies with something we haven't seen yet.

BTW you did *look* in the error console for an explanatory message
didn't you?

here's the link: http://www.csus.edu/org/bap/

as for errors. Its not generating any. I had it set up to throw an
alert with the fullHTML variable displayed and it returns all of the
formatted information as it should be. For whatever reason it just
does not want to be put in the innerHTML property of the div i'm
trying to assign it too. Works fine in IE.

Keep in mind that the javascript is still being built and i'm trying
to figure out ways to handle other items, so it is not the final final
version.
 
P

pr

Joseph said:
here's the link: http://www.csus.edu/org/bap/

as for errors. Its not generating any. I had it set up to throw an
alert with the fullHTML variable displayed and it returns all of the
formatted information as it should be. For whatever reason it just
does not want to be put in the innerHTML property of the div i'm
trying to assign it too. Works fine in IE.

Keep in mind that the javascript is still being built and i'm trying
to figure out ways to handle other items, so it is not the final final
version.

Thanks, that's a lot easier. As far as I can see you have two blissfully
small problems: firstly, in google.js you define the googleEntry object
thus:

function googleEntry(entryxml)
{
this.title
this.title= entryxml.getTitle().getText();
this.link
this.link= entryxml.getHtmlLink().getHref();
this.pubDate;
this.pubDate = entryxml.published
this.when;
this.where;
this.image;
...

and should define it thus:

function googleEntry(entryxml)
{
this.title = entryxml.getTitle().getText();
this.link = entryxml.getHtmlLink().getHref();
this.pubDate = entryxml.published
this.when = "";
this.where = "";
this.image = "";

But that just produces a blizzard of spurious warnings. More
importantly, in showGoogle() in the same file you disable any output
with this test:

if(document.getElementById(chanDiv).innerHTML.length<=5)

innerHTML.length is (wouldn't you know it?) 6. Try commenting out that
line and you should see some results.

To see more detailed error messages in Firefox, type 'about:config' in
the address (location) bar and change

javascript.options.strict

from false to true. You will see more warnings than you want in the
error console because you have Google code on your page and they can't
write JavaScript to save their lives; yet it should help you keep your
own code in shape. You could also look into the Firebug extension, which
a lot of people here recommend.

Cheers
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top