1 (edited by bd_sn 2012-06-20 10:04:26)

Topic: [SOLVED] JS function instead of ImageLinkURL

Dear all,

is it possible to execute a js function instead of opening a link? Adding "javascript:doSomething()" in config.xml and clicking the icon, nothing happens (= blank window). I read the whole documentation, could not found any API options for that.

Would be great if you can tell me more ;)
Regards, bd_sn

Re: [SOLVED] JS function instead of ImageLinkURL

Yes.
Include your JavaScript function in your gallery's HTML index page, such as:

<!--START JUICEBOX EMBED-->
<script src="jbcore/juicebox.js"></script>
<script>
    function doSomething() {
        alert("Hello world.");
    }
    new juicebox({
        containerId : 'juicebox-container'
    });
</script>
<div id="juicebox-container"></div>
<!--END JUICEBOX EMBED-->

... and then in your gallery's XML file, an <image> entry might look something like this:

<image imageURL="images/wide.jpeg"
thumbURL="thumbs/wide.jpeg"
linkURL="javascript: doSomething();"
linkTarget="_self">
<title>Welcome to Juicebox!</title>
</image>

Note that the linkTarget must be set to '_self'.

Re: [SOLVED] JS function instead of ImageLinkURL

Hey Steven,
thanks for your rapid response to my question :).

But it is not working as expected. Using the following line in config.xml, it always opens up a new window and does not execute the javascript function.

<image imageURL="content/focus.jpg" thumbURL="content/thumb.jpg" linkURL="javascript:testFunc();" linkTarget="_self">

Thanks, bd_sn

Re: [SOLVED] JS function instead of ImageLinkURL

Sorry, solved the problem - did not use the latest version of juicebox code :).
Have a nice day, bd_sn