0
"미리보기"링크를 생성하는 xsl 파일이 있습니다.XSL 파일에 자바 스크립트 파일 포함
<a>
<xsl:attribute name="href">
<xsl:text>#preview</xsl:text>
</xsl:attribute>
<xsl:attribute name="onclick">
<xsl:text>embeddedPreview("</xsl:text>
<xsl:text>http://docs.google.com/viewer?url=</xsl:text>
<!--Google can't reach a local development machines, so you may want to code in your production server, where Google downloads the file from-->
<!--<xsl:text>http://example.edu/</xsl:text>-->
<!-- Getting bitstreams by ID XMLUI: /xmlui/bitstream/id JSPUI: /jspui/retrieve -->
<xsl:text>/xmlui/bitstream/id/</xsl:text>
<xsl:value-of select="substring(@ID,6)"/>
<xsl:text>&embedded=true</xsl:text>
<xsl:text>");</xsl:text>
/xsl:attribute>
Preview
</a>
링크가 클릭 될 때마다 onclick 이벤트는 embeddedPreview라는 javascript 함수를 호출합니다. embeddedPreview 기능은 mylibrary.js에 저장됩니다
/**
* Creates an iframe with the specified source
* @REQUIRES jQuery
* @REQUIRES that there exists an element with ID preview-embed
*/
function embeddedPreview(source) {
if($("#embed").length > 0) {
//set the source to the location asked for
$("#embed").attr("http://19.46.1.34:8081/xmlui/handle/123456789", source);
} else {
//Create the embed iframe
$("#preview-embed").append("<iframe id='embed' src='"+source+"' width='100%' height='342px' style='border:none;'/>"); //requires jQuery
}
}
내가 미리보기 링크를 클릭 할 때마다 오류가 말을 발생
UnCaughtReferenceError: embeddedPreview is not defined
onclick
은 어떻게 XSL 파일에 자바 스크립트를 삽입하는?
내 대답이 도움이 되었습니까? 이걸 작품으로 가져 본 적이 있니? –