Re: Using onclick link attribute to get popup window

Posted by wimalopaan on
URL: https://discuss.asciidoctor.org/Using-onclick-link-attribute-to-get-popup-window-tp2964p2970.html

Just to answer myself: I managed to get a special click behaviour using the below Javascript in
the docinfo.html file.

A link like

link:{srcbase}/{srcdir}/Hello.java[Hello.java, role="red", window="_new"] 

is now opened in a new window(!) not tab and following clicks are going into the very same window.

The docinfo.html content:

<script src="http://code.jquery.com/jquery-2.1.3.min.js"></script>

<script type="text/javascript">
jQuery(document).ready(function(){
   jQuery('a[target^="_new"]').click(function(e) {
       var width = 600;
       var height = 400;
       window.open(this.href, 'newwindow', 'width=' + width + ', height=' + height + ', top=50, left=500');
       return false; 
   });
});
</script>