<script> tag doesn't close properly

主宰稳场 提交于 2019-12-10 19:45:56

问题


In my default.jspx which contains the basic layout for the page I am trying to import some jquery libraries as follows

<head>
    ...
    <spring:url value="/resources/js/lib/jquery-1.9.1.min.js" var="jquery_url" />
    <spring:url value="/resources/js/lib/jquery.tokeninput.js" var="jquery_tokeninput_url" />
    <script src="${jquery_url}" type="text/javascript"></script>    
    <script src="${jquery_tokeninput_url}" type="text/javascript"></script>
    <script type="text/javascript">
        $.noConflict();
    </script>
    <util:load-scripts />
    ...
</head>

but when the page is rendered in the browser the first script tag swallows the two others

<head>
...
<script type="text/javascript" src="/roo-inari/resources/js/lib/jquery-1.9.1.min.js">
//These lines are inside the first script tag
<script type="text/javascript" src="/roo-inari/resources/js/lib/jquery.tokeninput.js"/>
<script type="text/javascript">
        $.noConflict();
//The tag is closed here
</script>
<link href="/roo-inari/resources/dijit/themes/tundra/tundra.css" type="text/css" rel="stylesheet">
...

Any idea what might be causing this? The project is based on a spring roo generated web mvc scaffold. I am using Chrome v.25.


回答1:


The simple solution was to write a comment inside the tag so that it is not closed automatically. Silly me

<script src="${jquery_url}" type="text/javascript"><!-- required for some browsers --></script> 


来源:https://stackoverflow.com/questions/15716706/script-tag-doesnt-close-properly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!