2015-01-19 1 views
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>&amp;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 파일에 자바 스크립트를 삽입하는?

+0

내 대답이 도움이 되었습니까? 이걸 작품으로 가져 본 적이 있니? –

답변

1

주어진 오류가 embeddedPreview이 호출되었지만 찾을 수 없으므로 (정의되지 않음) XSLT가 올바른 변환을 수행했기 때문에 문제가 XSLT에 없습니다.

그래서 가능성은 다음과 같습니다

  • 당신은 태그에서 함수 정의를 넣어 깜빡
  • 함수 정의하기 전에 중단 컴파일 과정을 일으키는 자바 스크립트 오류가있을 수 있습니다

콘솔에서 자바 스크립트 오류를 ​​확인하고 문제가 해결되지 않거나 다른 오류를 발견하면 댓글을 달아주세요.

또한 수정하지 않으면 변환 후 변환 된 링크 (태그)를 게시 할 수 있다면 도움이됩니다.