开发者

HTML after iframe neglected

I'm currently stuck on a problem that looks a lot like this one at first hand, however the solution of that problem did not work in my case.

I have a tagx in which I have an iframe in which I'm setting the src attribute using jQuery to a certain value depending on the hyperlink clicked on. The tag is embedded by a jspx file mostly consisting of a springform. Everything works nicely except that code written directly below the iframe is not shown by the browser (tested in Firefox and Chrome, not sure for other browsers). Even code written in the jspx directly below the tag (which embeds the tag with the iframe) is not shown.

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>


What you need to do is insert a comment between the iframe tags. Some browsers do not allow empty tags. Inserting a comment in these tags will probably fix your problem. See the example below:

    <iframe id="editor" style='width: 800px; height: 800px' name="iframeId" frameborder="0"><!-- //required for browser compatibility --></iframe>
    <p>I am visible!</p>
</jsp:root>


This happened to me from a youtube embed in a <!doctype html> dom.

<iframe id="ytplayer" type="text/html" width="640" height="390"
    src="http://www.youtube.com/embed/M7lc1UVf-VE?autoplay=1&origin=http://example.com"
    frameborder="0"/>

The trick was to add a closing </iframe> tag, not a self-closing one:

<iframe id="ytplayer" type="text/html" width="640" height="390"
    src="http://www.youtube.com/embed/M7lc1UVf-VE?autoplay=1&origin=http://example.com"
    frameborder="0"></iframe>


Add some text inside iframe It will work.

<iframe id="ytplayer" type="text/html" width="640" height="390"
    src="http://www.youtube.com/embed/M7lc1UVf-VE?autoplay=1&origin=http://example.com"
    frameborder="0">some text</iframe>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜