diff --git a/Repositories/otago_eprints3/otago_eprints/cfg/cfg.d/eprint_render.pl b/Repositories/otago_eprints3/otago_eprints/cfg/cfg.d/eprint_render.pl index 60a5f6b..5eb7ba6 100755 --- a/Repositories/otago_eprints3/otago_eprints/cfg/cfg.d/eprint_render.pl +++ b/Repositories/otago_eprints3/otago_eprints/cfg/cfg.d/eprint_render.pl @@ -116,12 +116,18 @@ # onclick attribute to it. Note that the DOM documentation says # the NodeList is indexed from 0, but item(0) gives the wrong # element (?!?!). - $rendered_icon->getElementsByTagName( 'a' )->item( 1 )->setAttribute( - 'onclick', - "javascript:urchinTracker( '" . - $docpath . - "' );" - ); + # + # Need to check if it's defined, in case render_icon_link returns + # nothing (probably because of document security restrictions). + if ( defined ( $rendered_icon->getElementsByTagName( 'a' )->item( 1 ) ) ) + { + $rendered_icon->getElementsByTagName( 'a' )->item( 1 )->setAttribute( + 'onclick', + "javascript:urchinTracker( '" . + $docpath . + "' );" + ); + } $doctd->appendChild( $rendered_icon ); ## END NJS 2008-07-10 @@ -141,12 +147,18 @@ # the NodeList is indexed from 0, but item(0) gives the last # element instead of the first one; item(1)->(4) give the results # we want here. - $rendered_cite->getElementsByTagName( 'a' )->item( 1 )->setAttribute( - 'onclick', - "javascript:urchinTracker( '" . - $docpath . - "' );" - ); + # + # Need to check if it's defined, in case render_icon_link returns + # nothing (probably because of document security restrictions). + if ( defined ( $rendered_cite->getElementsByTagName( 'a' )->item( 1 ) ) ) + { + $rendered_cite->getElementsByTagName( 'a' )->item( 1 )->setAttribute( + 'onclick', + "javascript:urchinTracker( '" . + $docpath . + "' );" + ); + } $doctd->appendChild( $rendered_cite ); ## END NJS 2007-07-30