- Oracle APEX Cookbook(Second Edition)
- Marcel Van Der Plas Michel Van Zoest
- 470字
- 2021-07-23 15:34:43
Enhancing your application with the Google API>
In the previous recipe you could see how a JavaScript library such as jQuery can be used within APEX. Other JavaScript libraries can also be used, but they need first to be downloaded and installed. To make life easier for people who intend to use the various JavaScript libraries, Google introduced the Google API. Google puts the most well known JavaScript libraries online so you can reference them now without installing them into your own APEX environment! By the way, you can also use the JavaScript libraries in other languages such as PHP or just plain HTML with JavaScript.
To demonstrate this, we will make use of the scriptaculous
library. Suppose you have the following intranet home page:

We will let the Latest news section pulsate on loading the homepage.
How to do it...
- In the Application Builder, edit page 1.
- In the Page section, click on the Edit icon.
- In the HTML Header section, enter the following code in the HTML Header textarea:
<script src="http://www.google.com/jsapi" type="text/javascript"></script> <script type="text/javascript"> google.load("prototype", "1"); google.load("scriptaculous", "1"); function pulsate_news() { Effect.Pulsate('news', {'pulses' : 15, 'duration' : 3.0}); } google.setOnLoadCallback(pulsate_news);? </script> [9672_03_11.txt]
First, you need to load the libraries. This can be done with the
google.load()
function. The first argument is the library and the second argument is the version. In this case, we will use Version 1 of thescriptaculous
JavaScript library. By the way,scriptaculous
makes use of thePrototype
library, so this library has to be loaded first. The functionpulsate_news()
calls thepulsate
effect, and the functionpulsate_news
is called by thegoogle.setOnLoadCallback()
function. The first argument of thepulsate_news()
function is the ID of the affected div. The second argument is a list of options you can set. In this case, the news region pulsates 15 times in 3 seconds. - Click on the Apply Changes button.
Now we must set the ID of the affected div to news
.
- Click on the edit region link of the latest news region.
- In the Attributes section, enter
news
in the Static ID text field. - Click on the Apply Changes button.
- Run the page and see the Latest news region pulsate.
How it works...
Load the necessary libraries with the google.load
function. After that, create a function that calls the effect. To start the effect, use google.setOnLoadCallBack
. The last step is to give the affected object (a div or an item or other DOM object) an ID that will be used in the call to the JavaScript effect.
There's more...
For APEX 4.2, replace the code in step 3 by the following:
<script src="http://ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/scriptaculous.js"></script>
Add the following to the Execute when Page Loads textarea in the JavaScript section:
Effect.Pulsate('news', {'pulses' : 15, 'duration' : 3.0});
See also
- For more information on the Google API or
scriptaculous
, take a look at http://code.google.com/intl/nl/apis/ajaxlibs/documentation/index.html, http://code.google.com/apis/ajax/playground/?exp=libraries, or http://script.aculo.us.
- Proxmox High Availability
- Spring Cloud微服務架構(gòu)進階
- 互聯(lián)網(wǎng)安全的40個智慧洞見:2015年中國互聯(lián)網(wǎng)安全大會文集
- 網(wǎng)絡安全技術(shù)與解決方案(修訂版)
- SSL VPN : Understanding, evaluating and planning secure, web/based remote access
- 物聯(lián)網(wǎng)與無線傳感器網(wǎng)絡
- 6G新技術(shù) 新網(wǎng)絡 新通信
- IPv6網(wǎng)絡切片:使能千行百業(yè)新體驗
- CCNP TSHOOT(642-832)認證考試指南
- 4G小基站系統(tǒng)原理、組網(wǎng)及應用
- 網(wǎng)絡綜合布線(第2版)
- 無線傳感器網(wǎng)絡定位技術(shù)
- 移動物聯(lián)網(wǎng):商業(yè)模式+案例分析+應用實戰(zhàn)
- 物聯(lián)網(wǎng)的機遇與利用
- 小型局域網(wǎng)組建