【发布时间】:2011-11-02 01:43:47
【问题描述】:
我目前遇到了一个看起来很像 this 的问题,但是该问题的解决方案在我的情况下不起作用。
我有一个 tagx,其中有一个 iframe,我在其中使用 jQuery 将 src 属性设置为某个值,具体取决于单击的超链接。该标签由一个主要由 springform 组成的 jspx 文件嵌入。一切都很好,除了直接写在 iframe 下的代码没有被浏览器显示(在 Firefox 和 Chrome 中测试,不确定其他浏览器)。即使是直接在标签下方的 jspx 中编写的代码(将标签与 iframe 一起嵌入)也不会显示。
containerCreator.jspx:
<div xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:form="http://www.springframework.org/tags/form"
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:roo="urn:jsptagdir:/WEB-INF/tags"
xmlns:olo_elem="urn:jsptagdir:/WEB-INF/tags/olo/admin/element"
xmlns:spring="http://www.springframework.org/tags"
id="elementen_base"
version="2.0">
<spring:url value="/admin/element/saveContainerElementBean" var="save"/>
<form:form action="${save}" method="POST" modelAttribute="containerElementBean">
<input type="submit" value="sla op"/>
<olo_elem:containerCreator path="${path}" containerId="${id}"/>
<p>I'm not visible</p>
</form:form>
</div>
containerCreator.tagx:
<jsp:root xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:form="http://www.springframework.org/tags/form"
xmlns:olo_elem="urn:jsptagdir:/WEB-INF/tags/olo/admin/element"
xmlns:spring="http://www.springframework.org/tags" version="2.0">
<jsp:directive.attribute name="containerId" type="java.lang.Long" required="false" description="id van de container die wordt bevat, null indien nog geen container is gebonden" />
<jsp:directive.attribute name="path" type="java.lang.String" required="false" description="pad waarin het id van een nieuw containerelement wordt gezet"/>
<spring:url value="/admin/element/editContainer/${containerId}" var="existingLink" />
<spring:url value="/admin/element/newContainer" var="newLink" />
<script type="text/javascript">
function openExisting(){
$('#editor').attr('src', '${existingLink}');
$("#editor").show();
}
function openNew(){
$('#editor').attr('src', '${newLink}');
$("#editor").show();
}
$(document).ready(function(){
$("#editor").hide();
});
</script>
<c:choose>
<c:when test="${not empty id}">
<a onclick="javascript: openExisting()">Bewerk ContainerElement</a>
</c:when>
<c:otherwise>
<c:choose>
<c:when test="${not empty path}">
<input type="hidden" name="${path}" id="path" value=""/>
<a onclick="javascript: openNew()">Maak ContainerElement</a>
</c:when>
<c:otherwise>
Error: Geef containerId of tag op!
</c:otherwise>
</c:choose>
</c:otherwise>
</c:choose>
<iframe id="editor" style='width: 800px; height: 800px' name="iframeId" frameborder="0"> </iframe>
<p>I'm not visible</p>
</jsp:root>
【问题讨论】:
标签: jquery html spring iframe jstl