JavaScript手册 
目录
此参考中包含
的内容
轻松上手
简介
操作符
语句
核心
文档
窗口
表单
浏览器
事件和
事件句柄
LiveWire
数据库服务
进程管理服务
实用工具
全局函数
LiveConnect
的Java包
索引
版权
 
【目录】 【上一页】 【下一章】 【索引】

blob

服务器端对象. Provides functionality for displaying and linking to BLOb data.

服务器端对象
实现版本LiveWire 1.0

创建源

You do not create a separate blob object. Instead, if you know that the value of a cursor property contains BLOb data, you use these methods to access that data:

blobImageDisplays BLOb data stored in a database.
blobLinkDisplays a link that references BLOb data with a link.

Conversely, to store BLOb data in a database, use the blob function.

方法

blobImage

Displays BLOb data stored in a database.

方法源blob
实现版本LiveWire 1.0

语法

cursorName.colName.blobImage (format, altText, align, widthPixels, heightPixels, borderPixels, ismap)

参数

formatThe image format. This can be GIF, JPEG, or any other MIME image format. The accep表 formats are specified in the type=image section of the file $nshome\httpd-80\config\mime.types, where $nshome is the directory in which you installed your server. The client browser must also be able to display the image format.
altText(Optional) The value of the ALT attribute of the image tag. This indicates text to display if the client browser does not display images.
align(Optional) The value of the ALIGN attribute of the image tag. This can be "left", "right", or any other value supported by the client browser.
widthPixels(Optional) The width of the image in pixels.
heightPixels(Optional) The height of the image in pixels.
borderPixels(Optional) The size of the outline border in pixels if the image is a link.
ismap(Optional) True if the image is a clickable map. If this parameter is true, the image tag has an ISMAP attribute; otherwise it does not.

返回

An HTML IMG tag for the specified image type.

描述

Use blobImage to create an HTML image tag for a graphic image in a standard format such as GIF or JPEG.

The blobImage method fetches a BLOb from the database, creates a temporary file (in memory) of the specified format, and generates an HTML image tag that refers to the temporary file. The JavaScript runtime engine removes the temporary file after the page is generated and sent to the client.

While creating the page, the runtime engine keeps the binary data that blobImage fetches from the database in active memory, so requests that fetch a large amount of data can exceed dynamic memory on the server. Generally it is good practice to limit the number of rows retrieved at one time using blobImage to stay within the server's dynamic memory limits.

示例

示例 1. The following example extracts a row containing a small image and a name. It writes HTML containing the name and a link to the image:

cursor = connobj.cursor("SELECT NAME, THUMB FROM FISHTBL WHERE ID=2")
write(cursor.name + " ")
write(cursor.thumb.blobImage("gif"))
write("<BR>")
cursor.close()
These statements produce this HTML:

Anthia <IMG SRC="LIVEWIRE_TEMP11"><BR> 示例 2. The following example creates a cursor from the rockStarBios 表 and uses blobImage to display an image retrieved from the photos column:

cursor = database.cursor("SELECT * FROM rockStarBios
   WHERE starID = 23")
while(cursor.next()) {
   write(cursor.photos.blobImage("gif", "Picture", "left",
      30, 30, 0,false))
}
cursor.close()
This example displays an image as if it were created by the following HTML:

<IMG SRC="livewire_temp.gif" ALT="Picture" ALIGN=LEFT
   WIDTH=30 HEIGHT=30 BORDER=0>
The livewire_temp.gif file in this example is the file in which the rockStarBios 表 stores the BLOb data.

blobLink

Returns a link tag that references BLOb data with a link. Creates an HTML link to the BLOb.

方法源blob
实现版本LiveWire 1.0

语法

cursorName.colName.blobLink (mimeType, linkText)

参数

mimeTypeThe MIME type of the binary data. This can be image/gif or any other accep表 MIME type, as specified in the Netscape server configuration file $nshome\httpd-80\config\mime.types, where $nshome is the directory in which you installed your server.
linkTextThe text to display in the link. This can be any JavaScript string expression.

返回

An HTML link tag.

描述

Use blobLink if you do not want to display graphics (to reduce bandwidth requirements) or if you want to provide a link to an audio clip or other multimedia content not viewable inline.

The blobLink method fetches BLOb data from the database, creates a temporary file in memory, and generates a hypertext link to the temporary file. The JavaScript runtime engine on the server removes the temporary files that blobLink creates after the user clicks the link or sixty seconds after the request has been processed.

The runtime engine keeps the binary data that blobLink fetches from the database in active memory, so requests that fetch a large amount of data can exceed dynamic memory on the server. Generally it is good practice to limit the number of rows retrieved at one time using blobLink to stay within the server's dynamic memory limits.

示例

示例 1. The following statements extract a row containing a large image and a name. It writes HTML containing the name and a link to the image:

cursor = connobj.cursor("SELECT NAME, PICTURE FROM FISHTBL WHERE ID=2")
write(cursor.name + " ")
write(cursor.picture.blobLink("image/gif", "Link" + cursor.id))
write("<BR>")
cursor.close()
These statements produce this HTML:

Anthia <A HREF="LIVEWIRE_TEMP2">Link2</A><BR> 示例 2. The following example creates a cursor from the rockStarBios 表 and uses blobLink to create links to images retrieved from the photos column:

write("Click a link to display an image:<P>")
cursor = database.cursor("select * from rockStarBios")
while(cursor.next()) {
   write(cursor.photos.blobLink("image/gif", "Image " + cursor.id))
   write("<BR>")
}
cursor.close()
This example generates the following HTML:

Click a link to display an image:<P>
<A HREF="LIVEWIRE_TEMP1">Image 1</A><BR>
<A HREF="LIVEWIRE_TEMP2">Image 2</A><BR>
<A HREF="LIVEWIRE_TEMP3">Image 3</A><BR>
<A HREF="LIVEWIRE_TEMP4">Image 4</A><BR>
The LIVEWIRE_TEMP files in this example are temporary files created in memory by the blobLink method.


【目录】 【上一页】 【下一章】 【索引】

回页面顶部回页面顶部