[英]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. 我将Google Maps API与GWT一起使用,以在其中一个标记内创建带有推文的选项卡式信息窗口。 the source of the tweets is dynamically generated.
推文的来源是动态生成的。 heres the java code:
这是Java代码:
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.
发生的情况是该脚本将在firefox中执行,而IE和Chrome出于某种原因将避免运行该脚本。 Here is the html that is generated:
这是生成的html:
<div class="gwt-HTML">
<table bgcolor="#fdffd1" height="250" width="500"><tbody>
<tr>
<td align="left">
<h2><a style="color: rgb(122, 0, 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. 如果我将此代码复制到一个普通的html文件中并在google chrome中运行,它将可以正常工作。 if i open in IE, it will work, but only after i give it permission to run active content.
如果我在IE中打开,它将起作用,但是只有在我授予它运行活动内容的权限之后,它才能起作用。 if i open in firefox, it works fine without any problem.
如果我在Firefox中打开,它可以正常工作而没有任何问题。 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. 将生成的HTML发布到IE要求的权限的远程Web服务器上后,效果很好,它很可能仅与本地托管的文件有关。 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. 因此,这将意味着发布整个GWT项目,因为如果本地测试环境可能会导致问题。
The answer to my problem was that Infowindow content is static once it has been set. 我的问题的答案是Infowindow内容一旦设置便是静态的。 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.
出于某种原因,firefox能够执行在信息窗口中运行的脚本,但是无法修改其他浏览器解释这些脚本的方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.