javascript
ジャバスクは適当だとすぐ壊れるので危険です
携帯電話のjavascript対応(20080219)
普通はまるきり対応してないのでどうでもいいと思っていましたが、手持ちのsoftbank 821SHがかなりまじめに対応していたのでメモします。
821SHならいける
手持ちのSoftBank/1.0/821SH/SHJ001 Browser/NetFront/3.4 Profile/MIDP-2.0 Configuration/CLDC-1.1 -でjavascript使えました。普通の内蔵ブラウザ(NetFront/3.4)で思ったより使えます。フルブラウザの方は一度も起動したことがないので割愛します。資料を探してみましたがまったくないので、シャープが独自にONにしているみたいです。
ちなみにXMLHttpRequestは使えません。NetFront/3.4のオリジナルでは使えるみたいですが、スマートフォンとか、PS3とか、もっとリッチな環境じゃないとアクティブではないようです。面倒なのでやっていませんが、iframeが使えるのでそういう動作を模して動くライブラリならそれっぽいことができるかもしれません。
色々試した
ざっとwindowオブジェクトの中身document.write()したり、色々サンプルを見て回りました。雰囲気的にはIE4時代?な対応ぽいです。DOM関連は全部使えるようですし(getElementById(),getElementsByName()系)、面白いことに使う
- onblur
- onfocus
- onload
- onunload
- setInterval()
- setTimeout()
- alert()
- confirm()
- prompt()
がありなので、前時代的なものなら大半動きそうです。あと、821SHはマウスポインタを出せるので、onclickとか、onmouseoverも使えました(でもマウスポインタ使ってる人は居なさそう)。あとframeset,iframeでフレーム間通信もできました。
javascriptとは直接は関係ないですが、softbankの携帯は<input type="file">を使えるのが結構あるので、ファイルを利用したスクリプトもありです。
あとcookie、cssもほぼ全部使えます。
駄目だったのは、先にあげたXMLHttpRequest、ondblclick(onclickがありなら使えてもいいのに)、oncontextmenu(右クリックは禁止です! 右ボタンどこ!?)、moveBy(),moveTo(),resizeBy(),resizeTo()(常に全画面なので困る)は確認しました。
追加で制限される事としては、画面サイズ、使えるメモリ最大値でしょうか。馬鹿でかいスクリプトだと死んじゃうかもしれません。
使えそうなところ
やっぱりおすすめは由緒正しく、背景色をダイナミックに変えたり、ロールオーバーしたり(ていうかマウス系はむしろ面倒だ)、history.back()したり、テキストボックス内に文字を流したり、リアルタイム時計表示したり、背景に雪降らせたり、星流したり、モグラたたきゲームとかBMI計算機とか作ったりするのでしょうか。携帯ユーザーはjavascriptに慣れてない気がするので、色々びっくりさせて困らせましょう。<bgsound>も使えるので怖い画像がギャーーとかもできるはず。
ちなみに対応してる携帯ブラウザは他にどのくらいあるのでしょうか。
使えそうなオブジェクト一覧
windowオブジェクトから二階層目までkeyとvalueをdocument.write()してみた結果を置いておきます。オブジェクトがあっても動かなかったものあるので(ondblclickとか)全部は信頼できませんが目安に。
window,[object Window]
window,[object Window]
event,null
key,window
key2,key2
closed,false
crypto,undefined
defaultStatus,
document,[object HTMLDocument]
frameElement,null
frames,[object Window]
history,[object History]
innerHeight,350
innerWidth,240
length,0
location,http://mar33.sakura.ne.jp/
locationbar,[object Bar]
menubar,[object Bar]
name,
navigator,[object Navigator]
onblur,null
onfocus,null
onload,null
onunload,null
opener,null
outerHeight,undefined
outerWidth,undefined
pageXOffset,0
pageYOffset,0
parent,[object Window]
personalbar,[object Bar]
screen,[object Screen]
screenX,undefined
screenY,undefined
scrollX,0
scrollY,0
scrollbars,[object Bar]
self,[object Window]
status,
statusbar,[object Bar]
toolbar,[object Bar]
top,[object Window]
window,[object Window]
addEventListener,function addEventListener() { [native code] }
alert,function alert() { [native code] }
attachEvent,function attachEvent() { [native code] }
back,function back() { [native code] }
blur,function blur() { [native code] }
captureEvents,function captureEvents() { [native code] }
clearInterval,function clearInterval() { [native code] }
clearTimeout,function clearTimeout() { [native code] }
close,function close() { [native code] }
confirm,function confirm() { [native code] }
detachEvent,function detachEvent() { [native code] }
disableExternalCapture,function disableExternalCapture() { [native code] }
enableExternalCapture,function enableExternalCapture() { [native code] }
find,function find() { [native code] }
focus,function focus() { [native code] }
forward,function forward() { [native code] }
handleEvent,function handleEvent() { [native code] }
home,function home() { [native code] }
moveBy,function moveBy() { [native code] }
moveTo,function moveTo() { [native code] }
open,function open() { [native code] }
print,function print() { [native code] }
prompt,function prompt() { [native code] }
releaseEvent,function releaseEvent() { [native code] }
removeEventListener,function removeEventListener() { [native code] }
resizeBy,function resizeBy() { [native code] }
resizeTo,function resizeTo() { [native code] }
routeEvent,function routeEvent() { [native code] }
scroll,function scroll() { [native code] }
scrollBy,function scrollBy() { [native code] }
scrollTo,function scrollTo() { [native code] }
setInterval,function setInterval() { [native code] }
setTimeout,function setTimeout() { [native code] }
stop,function stop() { [native code] }
toString,function toString() { [native code] }
valueOf,function valueOf() { [native code] }
event,null
key,key
key2,valueOf
closed,false
crypto,undefined
defaultStatus,
document,[object HTMLDocument]
URL,http://mar33.sakura.ne.jp/
alinkColor,
all,[object HTMLCollection]
anchors,[object HTMLCollection]
applets,[object HTMLCollection]
attributes,null
bgColor,#000000
body,[object HTMLBodyElement]
characterSet,Shift_JIS
childNodes,[object NodeList]
compatMode,BackCompat
cookie,
doctype,undefined
document,null
documentElement,[object HTMLHtmlElement]
domain,mar3.lolipop.jp
embeds,[object HTMLCollection]
fgColor,#000000
firstChild,[object HTMLHtmlElement]
forms,[object HTMLCollection]
height,76
images,[object HTMLCollection]
implementation,[object DOMImplementation]
lastChild,[object HTMLHtmlElement]
lastModified,Tue, 19 Feb 2008 10:36:03 GMT
linkColor,
links,[object HTMLCollection]
localName,null
location,http://mar33.sakura.ne.jp/
namespaceURI,null
nextSibling,null
nodeName,#document
nodeType,9
nodeValue,null
onclick,null
oncontextmenu,null
ondblclick,null
onkeydown,null
onkeypress,null
onkeyup,null
onmousedown,null
onmousemove,null
onmouseout,null
onmouseover,null
onmouseup,null
onmousewheel,null
ownerDocument,null
parentNode,null
plugins,[object PluginArray]
prefix,null
previousSibling,null
referrer,
styleSheets,[object StyleSheetList]
textContent,null
title,Slow Love Down
vlinkColor,
width,234
addEventListener,function addEventListener() { [native code] }
appendChild,function appendChild() { [native code] }
attachEvent,function attachEvent() { [native code] }
clear,function clear() { [native code] }
cloneNode,function cloneNode() { [native code] }
close,function close() { [native code] }
createAttribute,function createAttribute() { [native code] }
createAttributeNS,function createAttributeNS() { [native code] }
createCDATASection,function createCDATASection() { [native code] }
createComment,function createComment() { [native code] }
createDocumentFragment,function createDocumentFragment() { [native code] }
createElement,function createElement() { [native code] }
createElementNS,function createElementNS() { [native code] }
createEntityReference,function createEntityReference() { [native code] }
createEvent,function createEvent() { [native code] }
createProcessingInstruction,function createProcessingInstruction() { [native code] }
createTextNode,function createTextNode() { [native code] }
detachEvent,function detachEvent() { [native code] }
dispatchEvent,function dispatchEvent() { [native code] }
getBoxObjectFor,function getBoxObjectFor() { [native code] }
getElementById,function getElementById() { [native code] }
getElementsByName,function getElementsByName() { [native code] }
getElementsByTagName,function getElementsByTagName() { [native code] }
getElementsByTagNameNS,function getElementsByTagNameNS() { [native code] }
hasAttributes,function hasAttributes() { [native code] }
hasChildNodes,function hasChildNodes() { [native code] }
importNode,function importNode() { [native code] }
insertBefore,function insertBefore() { [native code] }
isSupported,function isSupported() { [native code] }
normalize,function normalize() { [native code] }
open,function open() { [native code] }
removeChild,function removeChild() { [native code] }
removeEventListener,function removeEventListener() { [native code] }
replaceChild,function replaceChild() { [native code] }
toString,function toString() { [native code] }
valueOf,function valueOf() { [native code] }
write,function write() { [native code] }
writeln,function writeln() { [native code] }
frameElement,null
frames,[object Window]
window,[object Window]
event,null
key,frames
key2,key2
closed,false
crypto,undefined
defaultStatus,
document,[object HTMLDocument]
frameElement,null
frames,[object Window]
history,[object History]
innerHeight,350
innerWidth,240
length,0
location,http://mar33.sakura.ne.jp/
locationbar,[object Bar]
menubar,[object Bar]
name,
navigator,[object Navigator]
onblur,null
onfocus,null
onload,null
onunload,null
opener,null
outerHeight,undefined
outerWidth,undefined
pageXOffset,0
pageYOffset,0
parent,[object Window]
personalbar,[object Bar]
screen,[object Screen]
screenX,undefined
screenY,undefined
scrollX,0
scrollY,0
scrollbars,[object Bar]
self,[object Window]
status,
statusbar,[object Bar]
toolbar,[object Bar]
top,[object Window]
window,[object Window]
addEventListener,function addEventListener() { [native code] }
alert,function alert() { [native code] }
attachEvent,function attachEvent() { [native code] }
back,function back() { [native code] }
blur,function blur() { [native code] }
captureEvents,function captureEvents() { [native code] }
clearInterval,function clearInterval() { [native code] }
clearTimeout,function clearTimeout() { [native code] }
close,function close() { [native code] }
confirm,function confirm() { [native code] }
detachEvent,function detachEvent() { [native code] }
disableExternalCapture,function disableExternalCapture() { [native code] }
enableExternalCapture,function enableExternalCapture() { [native code] }
find,function find() { [native code] }
focus,function focus() { [native code] }
forward,function forward() { [native code] }
handleEvent,function handleEvent() { [native code] }
home,function home() { [native code] }
moveBy,function moveBy() { [native code] }
moveTo,function moveTo() { [native code] }
open,function open() { [native code] }
print,function print() { [native code] }
prompt,function prompt() { [native code] }
releaseEvent,function releaseEvent() { [native code] }
removeEventListener,function removeEventListener() { [native code] }
resizeBy,function resizeBy() { [native code] }
resizeTo,function resizeTo() { [native code] }
routeEvent,function routeEvent() { [native code] }
scroll,function scroll() { [native code] }
scrollBy,function scrollBy() { [native code] }
scrollTo,function scrollTo() { [native code] }
setInterval,function setInterval() { [native code] }
setTimeout,function setTimeout() { [native code] }
stop,function stop() { [native code] }
toString,function toString() { [native code] }
valueOf,function valueOf() { [native code] }
history,[object History]
current,undefined
length,1
next,undefined
previous,undefined
back,function back() { [native code] }
forward,function forward() { [native code] }
go,function go() { [native code] }
toString,function toString() { [native code] }
valueOf,function valueOf() { [native code] }
innerHeight,350
innerWidth,240
length,0
location,http://mar33.sakura.ne.jp/
hash,
host,mar3.lolipop.jp
hostname,mar3.lolipop.jp
href,http://mar33.sakura.ne.jp/
pathname,/
port,
protocol,http:
search,
assign,function assign() { [native code] }
reload,function reload() { [native code] }
replace,function replace() { [native code] }
toString,function toString() { [native code] }
valueOf,function valueOf() { [native code] }
locationbar,[object Bar]
visible,undefined
toString,function toString() { [native code] }
valueOf,function valueOf() { [native code] }
menubar,[object Bar]
visible,undefined
toString,function toString() { [native code] }
valueOf,function valueOf() { [native code] }
name,
navigator,[object Navigator]
appCodeName,Mozilla
appMinorVersion,undefined
appName,ACCESS NetFront
appVersion,4.08
browserLanguage,ja-JP
cookieEnabled,true
cpuClass,undefined
language,ja-JP
mimeTypes,[object MimeTypeArray]
onLine,true
oscpu,undefined
platform,SoftBank
plugins,[object PluginArray]
product,undefined
productSub,undefined
systemLanguage,ja-JP
userAgent,SoftBank/1.0/821SH/SHJ001 Browser/NetFront/3.4 Profile/MIDP-2.0 Configuration/CLDC-1.1
userLanguage,ja-JP
vendor,undefined
vendorSub,undefined
javaEnabled,function javaEnabled() { [native code] }
preference,function preference() { [native code] }
savePreferences,function savePreferences() { [native code] }
taintEnabled,function taintEnabled() { [native code] }
toString,function toString() { [native code] }
valueOf,function valueOf() { [native code] }
onblur,null
onfocus,null
onload,null
onunload,null
opener,null
outerHeight,undefined
outerWidth,undefined
pageXOffset,0
pageYOffset,0
parent,[object Window]
window,[object Window]
event,null
key,parent
key2,key2
closed,false
crypto,undefined
defaultStatus,
document,[object HTMLDocument]
frameElement,null
frames,[object Window]
history,[object History]
innerHeight,350
innerWidth,240
length,0
location,http://mar33.sakura.ne.jp/
locationbar,[object Bar]
menubar,[object Bar]
name,
navigator,[object Navigator]
onblur,null
onfocus,null
onload,null
onunload,null
opener,null
outerHeight,undefined
outerWidth,undefined
pageXOffset,0
pageYOffset,0
parent,[object Window]
personalbar,[object Bar]
screen,[object Screen]
screenX,undefined
screenY,undefined
scrollX,0
scrollY,0
scrollbars,[object Bar]
self,[object Window]
status,
statusbar,[object Bar]
toolbar,[object Bar]
top,[object Window]
window,[object Window]
addEventListener,function addEventListener() { [native code] }
alert,function alert() { [native code] }
attachEvent,function attachEvent() { [native code] }
back,function back() { [native code] }
blur,function blur() { [native code] }
captureEvents,function captureEvents() { [native code] }
clearInterval,function clearInterval() { [native code] }
clearTimeout,function clearTimeout() { [native code] }
close,function close() { [native code] }
confirm,function confirm() { [native code] }
detachEvent,function detachEvent() { [native code] }
disableExternalCapture,function disableExternalCapture() { [native code] }
enableExternalCapture,function enableExternalCapture() { [native code] }
find,function find() { [native code] }
focus,function focus() { [native code] }
forward,function forward() { [native code] }
handleEvent,function handleEvent() { [native code] }
home,function home() { [native code] }
moveBy,function moveBy() { [native code] }
moveTo,function moveTo() { [native code] }
open,function open() { [native code] }
print,function print() { [native code] }
prompt,function prompt() { [native code] }
releaseEvent,function releaseEvent() { [native code] }
removeEventListener,function removeEventListener() { [native code] }
resizeBy,function resizeBy() { [native code] }
resizeTo,function resizeTo() { [native code] }
routeEvent,function routeEvent() { [native code] }
scroll,function scroll() { [native code] }
scrollBy,function scrollBy() { [native code] }
scrollTo,function scrollTo() { [native code] }
setInterval,function setInterval() { [native code] }
setTimeout,function setTimeout() { [native code] }
stop,function stop() { [native code] }
toString,function toString() { [native code] }
valueOf,function valueOf() { [native code] }
personalbar,[object Bar]
visible,undefined
toString,function toString() { [native code] }
valueOf,function valueOf() { [native code] }
screen,[object Screen]
availHeight,350
availLeft,0
availTop,0
availWidth,240
colorDepth,16
height,400
pixelDepth,16
width,240
toString,function toString() { [native code] }
valueOf,function valueOf() { [native code] }
screenX,undefined
screenY,undefined
scrollX,0
scrollY,0
scrollbars,[object Bar]
visible,undefined
toString,function toString() { [native code] }
valueOf,function valueOf() { [native code] }
self,[object Window]
window,[object Window]
event,null
key,self
key2,key2
closed,false
crypto,undefined
defaultStatus,
document,[object HTMLDocument]
frameElement,null
frames,[object Window]
history,[object History]
innerHeight,350
innerWidth,240
length,0
location,http://mar33.sakura.ne.jp/
locationbar,[object Bar]
menubar,[object Bar]
name,
navigator,[object Navigator]
onblur,null
onfocus,null
onload,null
onunload,null
opener,null
outerHeight,undefined
outerWidth,undefined
pageXOffset,0
pageYOffset,0
parent,[object Window]
personalbar,[object Bar]
screen,[object Screen]
screenX,undefined
screenY,undefined
scrollX,0
scrollY,0
scrollbars,[object Bar]
self,[object Window]
status,
statusbar,[object Bar]
toolbar,[object Bar]
top,[object Window]
window,[object Window]
addEventListener,function addEventListener() { [native code] }
alert,function alert() { [native code] }
attachEvent,function attachEvent() { [native code] }
back,function back() { [native code] }
blur,function blur() { [native code] }
captureEvents,function captureEvents() { [native code] }
clearInterval,function clearInterval() { [native code] }
clearTimeout,function clearTimeout() { [native code] }
close,function close() { [native code] }
confirm,function confirm() { [native code] }
detachEvent,function detachEvent() { [native code] }
disableExternalCapture,function disableExternalCapture() { [native code] }
enableExternalCapture,function enableExternalCapture() { [native code] }
find,function find() { [native code] }
focus,function focus() { [native code] }
forward,function forward() { [native code] }
handleEvent,function handleEvent() { [native code] }
home,function home() { [native code] }
moveBy,function moveBy() { [native code] }
moveTo,function moveTo() { [native code] }
open,function open() { [native code] }
print,function print() { [native code] }
prompt,function prompt() { [native code] }
releaseEvent,function releaseEvent() { [native code] }
removeEventListener,function removeEventListener() { [native code] }
resizeBy,function resizeBy() { [native code] }
resizeTo,function resizeTo() { [native code] }
routeEvent,function routeEvent() { [native code] }
scroll,function scroll() { [native code] }
scrollBy,function scrollBy() { [native code] }
scrollTo,function scrollTo() { [native code] }
setInterval,function setInterval() { [native code] }
setTimeout,function setTimeout() { [native code] }
stop,function stop() { [native code] }
toString,function toString() { [native code] }
valueOf,function valueOf() { [native code] }
status,
statusbar,[object Bar]
visible,undefined
toString,function toString() { [native code] }
valueOf,function valueOf() { [native code] }
toolbar,[object Bar]
visible,undefined
toString,function toString() { [native code] }
valueOf,function valueOf() { [native code] }
top,[object Window]
window,[object Window]
event,null
key,top
key2,key2
closed,false
crypto,undefined
defaultStatus,
document,[object HTMLDocument]
frameElement,null
frames,[object Window]
history,[object History]
innerHeight,350
innerWidth,240
length,0
location,http://mar33.sakura.ne.jp/
locationbar,[object Bar]
menubar,[object Bar]
name,
navigator,[object Navigator]
onblur,null
onfocus,null
onload,null
onunload,null
opener,null
outerHeight,undefined
outerWidth,undefined
pageXOffset,0
pageYOffset,0
parent,[object Window]
personalbar,[object Bar]
screen,[object Screen]
screenX,undefined
screenY,undefined
scrollX,0
scrollY,0
scrollbars,[object Bar]
self,[object Window]
status,
statusbar,[object Bar]
toolbar,[object Bar]
top,[object Window]
window,[object Window]
addEventListener,function addEventListener() { [native code] }
alert,function alert() { [native code] }
attachEvent,function attachEvent() { [native code] }
back,function back() { [native code] }
blur,function blur() { [native code] }
captureEvents,function captureEvents() { [native code] }
clearInterval,function clearInterval() { [native code] }
clearTimeout,function clearTimeout() { [native code] }
close,function close() { [native code] }
confirm,function confirm() { [native code] }
detachEvent,function detachEvent() { [native code] }
disableExternalCapture,function disableExternalCapture() { [native code] }
enableExternalCapture,function enableExternalCapture() { [native code] }
find,function find() { [native code] }
focus,function focus() { [native code] }
forward,function forward() { [native code] }
handleEvent,function handleEvent() { [native code] }
home,function home() { [native code] }
moveBy,function moveBy() { [native code] }
moveTo,function moveTo() { [native code] }
open,function open() { [native code] }
print,function print() { [native code] }
prompt,function prompt() { [native code] }
releaseEvent,function releaseEvent() { [native code] }
removeEventListener,function removeEventListener() { [native code] }
resizeBy,function resizeBy() { [native code] }
resizeTo,function resizeTo() { [native code] }
routeEvent,function routeEvent() { [native code] }
scroll,function scroll() { [native code] }
scrollBy,function scrollBy() { [native code] }
scrollTo,function scrollTo() { [native code] }
setInterval,function setInterval() { [native code] }
setTimeout,function setTimeout() { [native code] }
stop,function stop() { [native code] }
toString,function toString() { [native code] }
valueOf,function valueOf() { [native code] }
addEventListener,function addEventListener() { [native code] }
alert,function alert() { [native code] }
attachEvent,function attachEvent() { [native code] }
back,function back() { [native code] }
blur,function blur() { [native code] }
captureEvents,function captureEvents() { [native code] }
clearInterval,function clearInterval() { [native code] }
clearTimeout,function clearTimeout() { [native code] }
close,function close() { [native code] }
confirm,function confirm() { [native code] }
detachEvent,function detachEvent() { [native code] }
disableExternalCapture,function disableExternalCapture() { [native code] }
enableExternalCapture,function enableExternalCapture() { [native code] }
find,function find() { [native code] }
focus,function focus() { [native code] }
forward,function forward() { [native code] }
handleEvent,function handleEvent() { [native code] }
home,function home() { [native code] }
moveBy,function moveBy() { [native code] }
moveTo,function moveTo() { [native code] }
open,function open() { [native code] }
print,function print() { [native code] }
prompt,function prompt() { [native code] }
releaseEvent,function releaseEvent() { [native code] }
removeEventListener,function removeEventListener() { [native code] }
resizeBy,function resizeBy() { [native code] }
resizeTo,function resizeTo() { [native code] }
routeEvent,function routeEvent() { [native code] }
scroll,function scroll() { [native code] }
scrollBy,function scrollBy() { [native code] }
scrollTo,function scrollTo() { [native code] }
setInterval,function setInterval() { [native code] }
setTimeout,function setTimeout() { [native code] }
stop,function stop() { [native code] }
toString,function toString() { [native code] }
valueOf,function valueOf() { [native code] }