最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to use Public API? - Stack Overflow

programmeradmin5浏览0评论

I came across a jQuery lightbox plug-in called PrettyPhoto. Seems very interesting. At the bottom of documentation I noticed a section about Public API, which I paste in its entirety below:

Version 2.5 introduced an easy to use API. You can now open prettyPhoto from anywere. The public API functions are the following:

$.prettyPhoto.open('images/fullscreen/image.jpg','Title','Description');
$.prettyPhoto.changePage('next');
$.prettyPhoto.changePage('previous');
$.prettyPhoto.close();

You can also open galleries using the API, just pass arrays to the open function.

images = ['images/fullscreen/image1.jpg','images/fullscreen/image2.jpg','images/fullscreen/image3.jpg'];
titles = ['Title 1','Title 2','Title 3'];
descriptions = ['Description 1','Description 2','Description 3']
$.prettyPhoto.open(images,titles,descriptions);

You can now open prettyPhoto from Flash or launch is from anywhere, anytime!

Great! I want to try it, but I have never dealt with APIs and have no idea how and where to plug the API code provided.

Can I create some sort of widget that will allow people placing it on other sites and open pictures there from my site? I'm lost. Google search did not yield any demos of its implementations.

Any nudge in the write direction will be highly appreciated.

I came across a jQuery lightbox plug-in called PrettyPhoto. Seems very interesting. At the bottom of documentation I noticed a section about Public API, which I paste in its entirety below:

Version 2.5 introduced an easy to use API. You can now open prettyPhoto from anywere. The public API functions are the following:

$.prettyPhoto.open('images/fullscreen/image.jpg','Title','Description');
$.prettyPhoto.changePage('next');
$.prettyPhoto.changePage('previous');
$.prettyPhoto.close();

You can also open galleries using the API, just pass arrays to the open function.

images = ['images/fullscreen/image1.jpg','images/fullscreen/image2.jpg','images/fullscreen/image3.jpg'];
titles = ['Title 1','Title 2','Title 3'];
descriptions = ['Description 1','Description 2','Description 3']
$.prettyPhoto.open(images,titles,descriptions);

You can now open prettyPhoto from Flash or launch is from anywhere, anytime!

Great! I want to try it, but I have never dealt with APIs and have no idea how and where to plug the API code provided.

Can I create some sort of widget that will allow people placing it on other sites and open pictures there from my site? I'm lost. Google search did not yield any demos of its implementations.

Any nudge in the write direction will be highly appreciated.

Share Improve this question edited Oct 24, 2010 at 23:10 deceze 523k88 gold badges800 silver badges943 bronze badges asked Oct 24, 2010 at 23:02 santasanta 12.5k51 gold badges161 silver badges266 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 5

This is Javascript, so you need to write some Javascript code that interacts with the PrettyPhoto object. Usually PrettyPhoto works semi-automagically, you just initialize it with a number of options and it'll find links on the current page and act only when the user clicks on these links. Using the API you can get it to display images or move between images on your mand though (i.e. you can write Javascript code that mands PrettyPhoto). "API" here just means "a bunch of public functions you can call." It should work as shown in the example, verbatim.

API stands for Application programming interface.

Every application that supports an API has it's own custom implementation. On your specific case PrettyPhoto made an API than can be used calling those very same functions you pasted on your code.

Here's a solution to launch prettyPhoto from Flash :

发布评论

评论列表(0)

  1. 暂无评论