官术网_书友最值得收藏!

Displaying web pages in your app

If you need to display a live web page in your mobile app, then this recipe is for you. In this recipe, you will learn how to create a display area in your app, retrieve web data, and display that data.

How to do it...

Follow these steps to display web pages in your app:

  1. Create a new main stack.
  2. Select the stack's card and drag an image area to display the web information.
  3. Select the image and then select the Group icon on the toolbar to make the image a group.
  4. Select the group and set the following properties:
    • Name: Browser
    • Width: 312
    • Height: 390
    • Location: 160, 225
  5. At the card level, enter the following code:
    local browserID
  6. Create a preOpenCard handler with the following code:
     on preOpenCard
     mobileControlCreate "browser"
     put the result into browserID
     mobileControlSet browserID, "visible", \
       "true"
     mobileControlSet browserID, "url", \
       "http://www.packtpub.com"
     end preOpenCard

    Note

    The preOpenCard message is sent to a card when you first go to the card and before the openCard message is sent. Using the on preOpenCard handler allows you to manipulate a card before it is visible to the user.

  7. Create a text field to display the URL. Name the field fld_URL.
  8. Next, create the following handler:
     on browserFinishedLoading pURL
     put pURL into field "fld_URL"
     end browserFinishedLoading

    The output is as follows:

How it works...

With only two objects and a few lines of code, we are able to retrieve and display web pages from the Internet directly in our mobile apps.

主站蜘蛛池模板: 张家港市| 六盘水市| 高要市| 通州区| 安庆市| 芦山县| 贵德县| 观塘区| 宜君县| 永胜县| 青海省| 黄平县| 红河县| 鲁甸县| 都江堰市| 平定县| 新密市| 新竹县| 陆川县| 兴城市| 阳信县| 梅州市| 肃宁县| 广元市| 高雄县| 兴安盟| 娄底市| 五峰| 会宁县| 横峰县| 柏乡县| 六盘水市| 华亭县| 定远县| 平南县| 望城县| 乐山市| 开原市| 泾源县| 湘乡市| 黄骅市|