views:

561

answers:

3

I am using gwt with google maps api and i have a set of tabbed infowindows. in one of them i want to have a recent tweets script running. it works fine in firefox, but it comes up as blank in ie and chrome. heres the HTML that im putting in the tab:

        HTML recentTweets = new HTML(
            "<body>"+
            "<div style='color: #ffffff; background-color: #010101'>"+
            "<script type='text/javascript' src='http://twitter.com/javascripts/blogger.js'&gt;&lt;/script&gt;"+
            "<script type='text/javascript' src='http://twitter.com/statuses/user_timeline/stephenathome.json?callback=twitterCallback2&amp;amp;count=3'&gt;&lt;/script&gt;"+
            "</div>"+
            "</body>");

does anyone understand why this may be happening? thanks!

+1  A: 

That HTML is, forgive me, horrible. You have quotes in the wrong places (for example in the style attribute of the div), have body inside a table inside a tr inside a td (it should be the other way around). It's highly probable that Firefox manages to do something with it, but other rendering engines give up and display nothing. The HTML should look like this:

<body>
<div style="color: #ffffff; background-color: #010101">
  <script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"&gt;&lt;/script&gt;
  <script type="text/javascrip\" src="http://twitter.com/statuses/user_timeline/Stephenathome.json?callback=twitterCallback2&amp;amp;count=5"&gt;&lt;/script&gt;
</div>
</body>

Which translated to Java is:

HTML recentTweets = new HTML(
    "<body>"+
    "<div style='color: #ffffff; background-color: #010101'>"+
      "<script type='text/javascript' src='http://twitter.com/javascripts/blogger.js'&gt;&lt;/script&gt;"+
      "<script type='text/javascript' src='http://twitter.com/statuses/user_timeline/Stephenathome.json?callback=twitterCallback2&amp;amp;count=5'&gt;&lt;/script&gt;"+
    "</div>"+
    "</body>");
Javier Badia
i know it looked bad, my fault. ive tried writing the code 30 different times today and that was the last way i tried before i decided to come here and ask. i edited the op.one thing you suggested that i thought may work was changing the double quotes to single quotes in java, but it didnt work. i have written the code so that it works in ie and chrome when i open it as an .html, but when i make it java, it only works in firefox. any ideas?
culov
Well, if this didn't help, I'm not sure I can help. I thought it was an HTML issue.
Javier Badia
+1  A: 

To add to what Javier Badia wrote, your best chance of making web pages that work in all popular browsers is to (1) use validators to make sure that your HTML and CSS adhere to standards, and (2) Understand which bits of the standard make certain browsers cranky.

There are many validators. I favor Marc Gueury's HTML Validator plugin for Firefox because it validates every page brought up without you having to ask it to. In the lower right corner of the browser window it puts a green checkbox or a red X right where it'll catch your eye. Having it "always on" makes it pretty much painless. Also, it validates offline, so there's no need to submit your page to an external server. Depending upon your needs, there may be other HTML validators that will suit you as well or better.

I won't recommend a CSS validator because I haven't found the good one yet.

Wayne Conrad
A: 

If this is part of a GWT project is it happening locally? If so the problem is most likely just due to restrictions on local files place the project on a remote web server and it should work fine.

Jeff Beck