Skip to Content
JAVASCRIPT網頁應用程式設計
book

JAVASCRIPT網頁應用程式設計

by Alex MacCaw
January 2013
Intermediate to advanced
332 pages
5h 23m
Chinese
GoTop Information, Inc.
Content preview from JAVASCRIPT網頁應用程式設計
104
|
第七章
方看到被拖曳元件的半透明圖樣。
addElement( 網頁元件 , x 座標軸 , y 座標軸 )
函式的功
能也很類似,它能讓你指定拖曳元件時,出現在滑鼠游標下方的元件為何。也就是說,
你可以自行定義一組網頁元件,並讓它成為拖曳其他元件時,出現在滑鼠游標下方的
圖案。
如果想讓使用者把網頁上的檔案拖到瀏覽器外面,可以將 setData() 的第一組參數值設
定為
DownloadURL
,再設定檔案儲存位置的 URL,讓瀏覽器知道該到哪裡下載檔案。
Gmail 就是利用這項功能,讓使用者能將電子郵件裡的附加檔案,直接從瀏覽器拖到桌
面上。
不過目前只有 Chrome 瀏覽器有支援這項功能,而且相關說明文件也尚未齊備。不過未
來其他瀏覽器新增這項功能的可能性應該不低,所以先加上這項功能倒也無傷大雅。
DownloadURL
格式所對應的設定值,是用冒號(
:
)來區隔開三項檔案資訊:MIME
型、檔案名稱,以及檔案儲存位置。
$("#preview").bind("dragstart", function(e){
e.originalEvent.dataTransfer.setData("DownloadURL", [
"application/octet-stream", // MIME 類型
"File.exe", // 檔案名稱
"http://example.com/file.png" // 檔案儲存位置
].join(":"));
});
HTML5 拖曳 / 置放 API ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

初めてのJavaScript 第3版 ―ES2015以降の最新ウェブ開発

初めてのJavaScript 第3版 ―ES2015以降の最新ウェブ開発

Ethan Brown, 武舎 広幸, 武舎 るみ
PHP编程:第4版

PHP编程:第4版

Kevin Tatroe, Peter MacIntyre
Strange Code

Strange Code

Ronald T. Kneusel
Perfecting Your Thinking Skills

Perfecting Your Thinking Skills

MIT Sloan Management Review

Publisher Resources

ISBN: 9789862766811