Using onclick link attribute to get popup window

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Using onclick link attribute to get popup window

wimalopaan
Hi all,

is it possible to pass the "onclick" attribute to a link-inline-macro.

I tested things like

:linkattrs:

link:url[url, onclick="function();"]

with no luck.

Any ideas?

Wilhelm
Reply | Threaded
Open this post in threaded view
|

Re: Using onclick link attribute to get popup window

wimalopaan
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>
Reply | Threaded
Open this post in threaded view
|

Re: Using onclick link attribute to get popup window

mojavelinux
Administrator
In reply to this post by wimalopaan

On Tue, Apr 7, 2015 at 2:05 AM, wimalopaan [via Asciidoctor :: Discussion] <[hidden email]> wrote:
link:url[url, onclick="function();"]

with no luck.

These attributes are not passed through, mostly due to security.

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. 


Cool trick!

Cheers,