我用的是GXT的感受器
我们有一个名为“仪表板”的web应用程序url = localhost:8080/dashboard/
我们有另一个名为issuetracker的We应用程序
url = localhost:2990/issuetracker/
现在,我在发布跟踪器web应用程序中有了一个速度模板,其中我给出了以下代码
<iframe src="localhost:8080/dashboard" width="500" height="600">
</iframe>当我单击仪表板web应用程序中的一个按钮时,问题跟踪器应用程序的url应该更改为"localhost:8080/issuetracker/issues?mqlVersion=25".。这25个值来自仪表板web应用程序。
当我尝试编写jsni代码时,没有一个值显示在最顶部的窗口的url中,即“localhost:2990/仙issuetracker/”
我哪里出问题了?任何建议。
发布于 2014-04-10 11:41:47
在JSNI中使用
$wnd而不是window。
尝试(清洁浏览器缓存)
JSNI
Window.Location.replace(url);
public static final native String getParentWindow() /*-{
return $wnd.parent.location.href;
}-*/;JSP/HTML
<script type="text/javascript">
function changeURL() {
try {
window.parent.location.href = 'http://localhost:8080/issuetracker/issues?mqlVersion=25';
} catch (e) {
window.location.href = 'http://localhost:8080/issuetracker/issues?mqlVersion=25';
}
}
</script>样本代码
JSP/HTML
<div>
<div id='myDiv'>hello</div>
<iframe src="localhost:8080/dashboard" width="500" height="600">
</iframe>
</div>仪表板入口点类:
public static final native Element getParentElementById(String id) /*-{
return $wnd.parent.document.getElementById(id);
}-*/;
....
public void onModuleLoad() {
getParentElementById("myDiv").setInnerHTML("hi");
} 输出:
将内部hello的myDiv替换为hi。
https://stackoverflow.com/questions/22986282
复制相似问题