admin管理员组文章数量:1026989
Hopefully this is a simple syntax question:
I want to create an onload statement that, when piled, will look as follows:
<body onload="location.href='#tutanchor'">
My expression language attempt is as follows:
<body th:attr="onload='location.href='+${anchorname}">
This doesn't work because it is missing the single quotes round the anchor. But if I add additional single quotes, thymeleaf cannot parse.
Any suggestions?
Hopefully this is a simple syntax question:
I want to create an onload statement that, when piled, will look as follows:
<body onload="location.href='#tutanchor'">
My expression language attempt is as follows:
<body th:attr="onload='location.href='+${anchorname}">
This doesn't work because it is missing the single quotes round the anchor. But if I add additional single quotes, thymeleaf cannot parse.
Any suggestions?
Share Improve this question edited Aug 27, 2015 at 0:00 gilly3 91.9k26 gold badges147 silver badges179 bronze badges asked Aug 26, 2015 at 23:56 JakeJake 4,68010 gold badges43 silver badges89 bronze badges1 Answer
Reset to default 2How about using '
?
<body th:attr="onload='location.href=''+${anchorname}+'''">
I'm not familiar with thymeleaf, so this may not work as I expect. The documentation suggests that \
is the escape character for quotes. If '
doesn't work, try escaping the quotes:
<body th:attr="onload='location.href=\''+${anchorname}+'\''">
It begs the question, why not just use a <script>
tag?
<script th:inline="javascript">
/*<![CDATA[*/
location.href = /*[[${anchorname}]]*/ '#';
/*]]>*/
</script>
Hopefully this is a simple syntax question:
I want to create an onload statement that, when piled, will look as follows:
<body onload="location.href='#tutanchor'">
My expression language attempt is as follows:
<body th:attr="onload='location.href='+${anchorname}">
This doesn't work because it is missing the single quotes round the anchor. But if I add additional single quotes, thymeleaf cannot parse.
Any suggestions?
Hopefully this is a simple syntax question:
I want to create an onload statement that, when piled, will look as follows:
<body onload="location.href='#tutanchor'">
My expression language attempt is as follows:
<body th:attr="onload='location.href='+${anchorname}">
This doesn't work because it is missing the single quotes round the anchor. But if I add additional single quotes, thymeleaf cannot parse.
Any suggestions?
Share Improve this question edited Aug 27, 2015 at 0:00 gilly3 91.9k26 gold badges147 silver badges179 bronze badges asked Aug 26, 2015 at 23:56 JakeJake 4,68010 gold badges43 silver badges89 bronze badges1 Answer
Reset to default 2How about using '
?
<body th:attr="onload='location.href=''+${anchorname}+'''">
I'm not familiar with thymeleaf, so this may not work as I expect. The documentation suggests that \
is the escape character for quotes. If '
doesn't work, try escaping the quotes:
<body th:attr="onload='location.href=\''+${anchorname}+'\''">
It begs the question, why not just use a <script>
tag?
<script th:inline="javascript">
/*<![CDATA[*/
location.href = /*[[${anchorname}]]*/ '#';
/*]]>*/
</script>
本文标签: thymeleaf javascript onloadlocationhrefStack Overflow
版权声明:本文标题:thymeleaf javascript onload=location.href - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745542986a2155268.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论