【发布时间】:2016-03-07 19:26:06
【问题描述】:
我在 JSP adobe Cq5 中有以下 scriptlet,现在正在迁移到 Adobe Sightly/HTL。 有以下代码,点击锚链接会打开一个新窗口,同样的功能必须写得很清楚。你能帮帮我吗?
<% if(!properties.get("buttonlabel","").equals("")){
String targetUrl ="#";
targetUrl = properties.get("buttonurl","#");
if(targetUrl.startsWith("/content")){
targetUrl = targetUrl+".html";
}
String target = "_self";
if(currentNode.hasProperty("openWindow")){
target = "_blank";
}
%>
<!--
<div class="fcdetails-button-holder">
<a href='<%=targetUrl%>' target ='<%=target%>' name='<%=properties.get("buttonlabel","Title")%> button' id="wp-ctoa_button" class="button" role="button"><%=properties.get("buttonlabel","Title")%></a>
</div>
-->
<div class="fcdetails-button-holder">
<button type="button" id="wp-ctoa_button" class="button" onclick="redirect()"><%=properties.get("buttonlabel","Title")%></button>
</div>
<script type="text/javascript">
function redirect()
{
var url = "<%=targetUrl%>";
window.open(url,"<%=target%>");
}
</script>
【问题讨论】: