Setting the title of the HTML wrapper 设置浏览器的title

本文介绍如何使用BrowserManager的setTitle()方法来更改HTML包装器的标题栏名称,并通过一个实例展示了如何根据用户输入更新浏览器标题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

You can use the BrowserManager's setTitle() method to set the title in your HTML wrapper. This shows up as the name of the web page in the title bar of the browser. When you first initialize the BrowserManager, you set the value of the title in the second parameter to the init() method.

The following example sets the initial value of the title to "Welcome". It then changes the title depending on the name and hometown that you enter in the TextInput fields.

<?xml version="1.0" encoding="utf-8"?>
<!-- deeplinking/TitleManipulationExample.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
    layout="vertical" 
    historyManagementEnabled="false" 
    creationComplete="init();"
>    
    <mx:Script>
    <![CDATA[
        import mx.managers.BrowserManager;
        import mx.managers.IBrowserManager;
        import mx.events.BrowserChangeEvent;

        private var bm:IBrowserManager;

        private function init():void {
            bm = BrowserManager.getInstance();
            bm.init("", "Welcome!");
        }

        public function updateTitle(e:Event):void {
            bm.setTitle("Welcome " + ti1.text + " from " + ti2.text + "!");
        }
    ]]>
    </mx:Script>
    
    <mx:Form>
        <mx:FormItem label="Name:">
            <mx:TextInput id="ti1"/>
        </mx:FormItem>
        <mx:FormItem label="Hometown:">
            <mx:TextInput id="ti2"/>
        </mx:FormItem>
        <mx:Button id="b1" click="updateTitle(event)" label="Submit"/>
    </mx:Form>
</mx:Application>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值