【发布时间】:2011-04-17 03:56:27
【问题描述】:
我需要在 UIBinder 的一个 div 中集成以下脚本:
<!-- Begin: adBrite, Generated: 2011-04-14 8:40:27 -->
<script type="text/javascript">
var AdBrite_Title_Color = '66B5FF';
var AdBrite_Text_Color = '000000';
var AdBrite_Background_Color = 'FFFFFF';
var AdBrite_Border_Color = 'CCCCCC';
var AdBrite_URL_Color = '008000';
try{var AdBrite_Iframe=window.top!=window.self?2:1;var AdBrite_Referrer=document.referrer==''?document.location:document.referrer;AdBrite_Referrer=encodeURIComponent(AdBrite_Referrer);}catch(e){var AdBrite_Iframe='';var AdBrite_Referrer='';}
</script>
<span style="white-space:nowrap;"><script type="text/javascript">document.write(String.fromCharCode(60,83,67,82,73,80,84));document.write(' src="http://ads.adbrite.com/mb/text_group.php?sid=123&zs=123&ifr='+AdBrite_Iframe+'&ref='+AdBrite_Referrer+'" type="text/javascript">');document.write(String.fromCharCode(60,47,83,67,82,73,80,84,62));</script>
<a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=123&afsid=1"><img src="http://files.adbrite.com/mb/images/adbrite-your-ad-here-leaderboard.gif" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="14" height="90" border="0" /></a></span>
<!-- End: adBrite -->
GWT 编译器抱怨 & 符号,所以我将它们更改为 &amp;。
我还注意在文件顶部声明以下内容,以便正确解析 & 实体:
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
这至少允许我编译代码,但生成的页面呈现为&amp; 而不是&,这当然会破坏脚本。
我怎样才能正确地转义与号,以便脚本正常运行?有没有办法在我的加载器 html/jsp 中声明这个脚本,并让它呈现到我选择的 div 中?我在 Adbrite 的网站上找不到太多文档。
最后,Adbrite 真的有必要用String.fromCharCode 废话隐藏脚本来自远程站点的事实吗?据推测,这样做是为了防止某种 XSS 过滤起作用。
谢谢
【问题讨论】:
标签: javascript gwt uibinder