Dynamically generated javascript not executing in Chrome or IE, works in Firefox
I'm using the google maps API with GWT to create a tabbed infowindow with tweets inside one of the markers. the source of the tweets is dynamically generated. heres the java code:
HTML recentTweets = new HTML(
"<div>"+
"<script type='text/javascript' src='http://twitter.com/javascripts/blogger.js'></script>"+
"<script type='text/javascript' src='http://twitter.com/statuses/user_timeline"+twitterUser+".json?callback=twitterCallback2&count=3'></script>"+
"</div>"
);
I have identified the problem, but I need a workaround. What happens is that the script will be executed in firefox, while IE and Chrome will, for some reason, avoid running it. Here is the html that is generated:
<div class="gwt-HTML">
<table bgcolor="#fdffd1" height="250" width="500"><tbody>
<tr>
<td align="left">
<h2><a style="color: rgb(122, 0开发者_JAVA技巧, 69);" ;="" href="http://www.eatphamish.com" target="_blank">
<img src="http://a1.twimg.com/profile_images/334307090/autoscale-100x100_bigger.png" height="48" width="48"><font color="#7a0045">stephencolbert</font></a></h2></td></tr>
<tr>
<div id="twitter_update_list" style="color: rgb(0, 0, 0); font-size: 12px;"></div>
<script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
<script type="text/javascript" src="http://twitter.com/statuses/user_timeline/stephencolbert.json?callback=twitterCallback2&count=5"></script>
</tr></tbody></div>
if i copy this code into a plain html file and run it in google chrome, it will work. if i open in IE, it will work, but only after i give it permission to run active content. if i open in firefox, it works fine without any problem. does anyone know how i can get this code to work without asking for permission in all the major browsers?? Thanks!
The HTML you generated worked fine once posted on a remote web server the permission IE is asking for is most likely only related to locally hosted files. Try posting on some web site and it should work fine for you.
So that would mean posting the whole GWT project because the test environment if local may be causing the problem.
The answer to my problem was that Infowindow content is static once it has been set. For some reason, firefox is able to execute script running inside an infowindow, but theres no way to modify how other browsers interpret those scripts.
精彩评论