joomla 1.5——JDocument类用法

文档类,提供一个容易的接口解析和显示文件

Method Description
__construct 构造函数
addScript 增加一个连接到页
addScriptDeclaration 增加脚本到页
addStyleDeclaration 增加一个stylesheet声明到页
addStyleSheet 增加一连接的stylesheet到页
getBase 返回本文的基本URI
getBuffer 得到本文缓冲的内容
getCharset 返回本文charset 内码
getDescription 返回页的标题
getDirection 返回文件语言
getGenerator 返回文档创建者
getHeadData 得到本文头数据
getInstance 返回在全局 JDocument对象
getLanguage 得到语言.
getLink 得到文档的URL
getMetaData 得到meta标签
getTitle 得到文档标题
getType 得到文档类型
loadRenderer 随机装载
render 输出文档
setBase 设置文档的e基本URI
setBuffer 设置本文缓冲的内容
setCharset 设置本文charset
setDescription 设置本文的描述
setDirection 设置全局文件声明。 缺省左到右(ltr)。
setGenerator 设置文本创建者
setHeadData 设置文本头信息
setLanguage 设置语言.
setLineEnd 设置线结尾样式对Windows、Mac、Unix或者自定义串。
setLink 设置文档链接
setMetaData 设置metai标签
setMimeEncoding 设置被送到浏览器的本文MIME内码
setModifiedData 定本文修改过的日期
setTab 设置串被用于内嵌HTML
setTitle 设置文档标题
setType 设置文档类型.

方法应用:

addScript()
意义:增加一个连接到页
语法:void addScript (string $url, [string $type = "text/javascript"])
string $url: URL to the linked script
string $type: Type of script. Defaults to 'text/javascript'
实际应用:
$temp =& Jfactory::getDocument();
$temp->addscript(JURI::base().'includes/js/overlib_mini.js');
结果:在head部分插入一段js


addScriptDeclaration()
意义:增加脚本到页头
语法:void addScriptDeclaration (string $content, [string $type = 'text/javascript'])
string $content: Script
string $type: Scripting mime (defaults to 'text/javascript')
实际应用:
$temp =& Jfactory::getDocument();
$script = "alert( 'A script has been added to the page!' );";
$temp->addScriptDeclaration($scirpt);


getBase()
意义:返回本文的基本URI
语法:string getBase ()
实际应用:
$temp =& Jfactory::getDocument();
echo $temp->getBase();


getBuffer()
意义:得到本文缓冲的内容
语法: getBuffer ()
实际应用:
$temp =& Jfactory::getDocument();
echo $temp->getBuffer();


getInstance()
意义:返回在全局JDocument对象
语法:object The &getInstance ([type $type = 'html'], [ $attributes = array()])
type $type: The document type to instantiate
$attributes
实际应用:
$temp =& Jfactory::getDocument();
$temp->getInstance('html'); //生成jdocumenthtml对象.
$temp->getInstance('error');//生成 jdocumenterror对象.
$temp->getInstance('feed');//生成 jdocumentfeed对象.



setBuffer()
意义:设置本文缓冲的内容
语法:void setBuffer (string $content)
string $content: The content to be set in the buffer
实际应用:
$temp =& Jfactory::getDocument();
echo $temp->setBuffer();


setDirection()
意义: 设置全局文件声明。 缺省左到右(ltr)。
语法:void setDirection ([ $dir = "ltr"], string $lang)
string $lang
$dir
实际应用:
$temp =& Jfactory::getDocument();
echo $temp->setDirection();


setGenerator()
意义: 设置文本创建者
语法:void setGenerator (string $generator)
string $generator
实际应用:
$temp =& Jfactory::getDocument();
echo $temp->setGenerator();


setHeadData()
意义: 设置文本头信息
语法:void setHeadData (array $data)
array $data: The document head data in array form
实际应用:
$temp =& Jfactory::getDocument();
echo $temp->setHeadData();


setLanguage()
意义: 设置语言
语法:void setLanguage ([string $lang = "en-gb"])
string $lang
实际应用:
$temp =& Jfactory::getDocument();
echo $temp->setLanguage();


setLineEnd()
意义: 设置线结尾样式对Windows、Mac、Unix或者自定义串。
语法:void setLineEnd (string $style)
string $style: "win", "mac", "unix" or custom string.
实际应用:
$temp =& Jfactory::getDocument();
echo $temp->setLineEnd();


setLink()
意义: 设置文档链接
语法:void setLink (string $url)
string $url: A url
实际应用:
$temp =& Jfactory::getDocument();
$link=”www.joomla.org”;
$temp->setLink($link);


setMetaData()
意义: 设置meta标签
语法:void setMetaData (string $name, string $content, [bool $http_equiv = false])
string $name: Value of name or http-equiv tag
string $content: Value of the content tag
bool $http_equiv: META type "http-equiv" defaults to null
实际应用:
$temp =& Jfactory::getDocument();
$temp->setMetaData('Publisher', 'joomla! Documentation Team!');
result:
<meta name="Publisher" content="Joomla! Documentation Team" />


setMimeEncoding()
意义: 设置被送到浏览器的本文MIME内码
语法:void setMimeEncoding ([string $type = 'text/html'])
string $type.
实际应用:
$temp =& Jfactory::getDocument();
$temp->setMimrEncoding('application/xml'));


setModifiedDate()
意义: 定本文修改过的日期
语法:void setModifiedDate (string $date)
string $date
实际应用:
$temp =& Jfactory::getDocument();
$temp->setModifiedDate($date));
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值