简体   繁体   English

无法在Chrome或IE中执行的动态生成的JavaScript在Firefox中有效

[英]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&amp;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&amp;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.

相关问题 Javascript可在Firefox中运行,但不能在IE或Chrome中运行 - Javascript working in firefox but not IE or chrome NoSuchElementException:无法找到具有id的元素/在FireFox和Chrome中工作正常,但在IE中无法正常工作 - NoSuchElementException : Unable to find element with id / Works fine in FireFox and Chrome but not in IE 用于列表框选择的Selenium Java代码在Chrome和IE上有效,但在Firefox上不起作用 - Selenium Java code for Listbox selection works on Chrome and IE, but not Firefox Httpservletrequest无法识别动态生成的Javascript输入字段? 仅在Chrome中? - Dynamically generated Javascript input fields are not recognized by Httpservletrequest??? ONLY in Chrome? Firefox 52.4.1上的Java Applet“ClassNotFoundException” - 适用于IE - Java Applet “ClassNotFoundException” on Firefox 52.4.1 - works on IE Java停止在Firefox中工作。 在IE中工作 - Java stopped working in Firefox. Works in IE Firefox不是使用Geckodriver和Selenium推出的 - 它适用于Chrome - Firefox is not launched using Geckodriver and Selenium - It works with Chrome Selenium:用于前置文本的sendKeys在Chrome中有效,但在Firefox中无效 - Selenium: sendKeys to prepending text works in Chrome but not Firefox Java applet可在appletviewer,Safari和Firefox中使用,但不能在Chrome中使用 - Java applet works in appletviewer, Safari and Firefox, but not Chrome 发送动态生成的 javascript 文件 - Sending dynamically generated javascript file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM