jstl嵌套JavaScript

问题说明:在jsp中会通过后台传值来判断是否关闭dialog,并且可能需要往弹出的父窗体传值,父窗体可能是一个iframe,因此需要使用在jstl判断后台传值,插入JavaScript代码向父窗体传值。

    <!--jstl中使用test判断后台传值-->
    <c:if test="${pd.state == 1 }"> 
    
		<span class="green">更新成功</span>
		<input id="NEWPIC" type="hidden" value="${pd.LIVEPICURL}"/>

		<script type="text/javascript">

			var pic = $("#NEWPIC").val();
			
            //获取当前父窗体,如果多个iframe最好使用id来进行筛选
			var tops = $("#panel iframe:visible",window.parent.document)[0];
            //切记,iframe要使用contentWindow.document来获取document		
			var topFrame= $(tops.contentWindow.document).find("#LiveImageURL").attr("name",pic);

		</script>

	</c:if>
原文地址:https://www.cnblogs.com/a8167270/p/5112748.html