2011/5/10 以下の訂正をしました。 s/prefetch/preflight/g JavaScriptのクロスドメイン通信で微妙な話があったので書いてみます。ちなみにクライアントサイドJavaScriptの話です。下記仕様に敬意を表して以下ではクロスオリジンと書きます。一般にクロスドメイン通信と呼ばれているものと同じ意味で使います。 Cross-Origin Resource Sharing XMLHttpRequest2(XHR2) WebブラウザからXMLHttpRequest(XHR)で外部のWeb APIを直接叩こうとするとクロスオリジンの制限に当たります。制限の必要性は次の説明がわかりやすいのでリンクを張っておきます。 Same-Originポリシーの必要性 クロスオリジン制限がある中でWebブラウザから直接Web APIを叩こうと先人は知恵を絞ってきました。iframe
今日は、 JavaScript の XMLHttpRequest オブジェクトの使い方を調べてみたので、それをご紹介しようと思います。 XMLHttpRequest はサーバーに対して HTTP リクエストを発行するためのオブジェクトで、 Ajax の A (Asynchronous) を司る中核技術です。これにより、Web ページを切り替えることなくサーバーからデータを取得し、ページ内容を更新することができます。 さあ、一緒に Ajax の世界へと足を踏み入れましょう!(^^) 使用方法 それでは、XMLHttpRequest オブジェクトの使用方法を順を追ってご紹介します。 XMLHttpRequest オブジェクトの作成 XMLHttpRequest オブジェクトを作成する方法は、 Firefox, Opera と IE で異なります。 Firefox, Opera の場合は単に X
第19回目の本勉強会は、7月13日に慶応義塾大学の日吉キャンパスをお借りして開催しました。今回のテーマは「HTML5を用いたサイト開発プラクティス」で、HTML5時代に伴ったWebサイト開発のHOW TOを中心に2つのメインセッションと3つのショートセッションの講演がありました。本稿では、本勉強会の模様をレポートします。 PJAX ~HTML5時代のAJAXサイトプラクティス~ 最初にPJAXという手法について、NTTコミュニケーションズの小松さんから講演いただきました。 最近では、AJAXを使ってページの切り替えをせずにコンテンツを動的に切り替えるサイトが増えてきました。これらのサイトは、従来のような画面全体を切り替える方式に比べて通信量を減らすことができますし、何よりもユーザビリティをより良くすることができます。 しかし、AJAXを使ったサイトはいくつかの問題点を抱えています。 ブラウ
Tim Bray氏のブログ記事を解説したものです。Tim Bray氏はXMLの生みの親であり、最近はGoogle Developer AdvocateとしてAndroidの普及に務めています。Twitterをはじめ、最近のWebサービスにて「twitter.com/#!/timbray」のようにURLに「#!」というhash-bang(shebang)が含まれるのをよく目にしますが、Tim氏はこの流行に批判の意を示しています。 hash-bangを含むURLはAjaxを利用するために考えられたしくみです。#以降は単なるフラグメントとして処理されるため、サーバは#より前のURLを解釈しコンテンツを出力します。そしてブラウザにてJavaScriptが#以降を解釈し、以降のパスに相当するコンテンツをAjaxにて取得しコンテンツを書き換えます。このしくみができた背景は、Ajax後のコンテンツをSE
pjaxの前にpushStateとは AjaxとjQueryの説明は不要として、pushStateとはなんぞや。 pushStateを使ってブラウザの履歴に対する操作をし、HTMLの一部のみを書き換える動作でもブラウザの戻る/進む機能を実現できる方法のひとつ。Ajaxなページを再現し、かつURLを見慣れた方法で自然にpermalinkを表現できる。 有名なところではGitHubで使われてるアレ。 hash fragment (/#!/) ブラウザの履歴を機能させるため、URL の fragment (#) を使ってAjaxなページを実現する方法。一時期もてはやされた感があるが、さらなる「#!」URL批判 - karasuyamatenguの日記 など合理的な反論があり、これから導入するのはためらわれるところ。 有名なところではTwitterで使われているあの厄介者。 pjaxとは pjax
Notimo Demos site 利用者に対し非常に分かりやすい通知を行うためのJavaScriptライブラリ「Notimoo」。 次のリンクをクリックしてみてください。 → 通知を表示してみる ページの右上にフェードインで表示するのはなかなかインパクトが大きいですね。 スクロールしても、いやみではない感じにちゃんとついてきてくれます。 使い方もかなり簡単で、必要なJSとCSSを読み込んだ後、インスタンスをnewして show メソッドを呼び出すだけです。 showは2回連続で呼び出しても、ちゃんと1個目と区別して表示してくれます。 <script type="text/javascript"> var notimooManager = new Notimoo(); // 通知を表示 notimooManager.show({ title: 'タイトル', message: 'メッセージ
seekAttention 注目箇所だけハイライトのアニメーションで強調。 スクロール・ドラッグなど操作関連のjQueryのプラグイン
はてなブックマーク(以下「はてブ」)がリニューアルされ、ブラウザからブックマークレットでブックマーク登録(以下「ブクマ登録」)しようとすると、図1の画面が現れるようになった。「こちらから再設定をお願いします」と指示されているが、この指示に従ってはいけない。ここで提供されている新型ブックマークレットは使ってはいけない。(この指示には従わなくてもブクマ登録はできる。) 新型ブックマークレットを使用すると図2の画面となる。ブクマ登録しようとしているWebサイト(通常、はてな以外のサイト)上に、はてブの画面のウィンドウが現れている。これは、Ajaxと共に近年よく使われるようになった「ページ内JavaScriptウィンドウ」である。(ポップアップウィンドウとは違い、ウィンドウをドラッグしてもブラウザの外に出すことはできず、あくまでも表示中のページ上のコンテンツであることがわかる。)
GoogleからGoogle AJAX APIを拡張する新しいサービス「The AJAX Libraries API」が公開された。The AJAX Libraries APIはGoogleのサイトで人気のある有益なJavaScriptライブラリを提供しようというもの。これまでYUIであればYahoo!、DojoであればAOLなどが同類のサービスを提供していたが、特定のJavaScriptライブラリに限定することなく有益であれば配布に追加するというポリシーをもっている点が新しい。 JavaScriptライブラリを活用するタイプのWebアプリケーションは数多くある。結果として、何度も似たようなJavaScriptライブラリをダウンロードしていることになり、このままいけば今後ライブラリ自体のサイズの巨大化や多くのサービスの登場でライブラリダウンロード総量は増加することになる。 The AJAX
twitter facebook hatena google pocket 米大統領選でクリントン氏と壮絶な攻防を繰り広げるオバマ氏のサイトでも使用されるなど、巷で大人気のjQuery。 今回はjQueryの関連サイトを紹介します。 追記: 2008/2/8 2サイト 2008/5/29 2サイト 2008/6/25 1サイト 2008/7/9 5サイト(jQuery UI系・Cheet Sheetを集めました) sponsors Reference ・jQuery リファレンス:v1.0.x、1.2.x ・jQuery 1.2 ドキュメント日本語訳 ・jQuery 開発者向けメモ:v1.1.x ・jQuery日本語リファレンス:v1.2.6 HowTo / Review ・jquery.jsを読み解く(追記:2008/2/8) ・jQueryの魔法 ・ニュータイプなJSライブラリjQue
Shadowbox.jsは、Prototype、jQuery、YUI、Extなど複数のJavaScriptのライブラリに対応した、画像や動画などを拡大表示できるLightbox風のスクリプトです。 Shadowbox.js Media Viewer デモ ダウンロード Shadowbox.jsは複数のライブラリに対応しているというだけでもすごいですが、画像や動画の拡大表示にもさまざまなオプションがあり、多数あるLightbox風スクリプトの中でも充実した機能を持っていると思います。 下記に主な特徴を挙げます。 拡大する際のコードは、簡易です。 <a href="image.jpg" rel="shadowbox">Image</a> 併用するJavaScriptのライブラリは、下記の中から好きなものを選べます。 jQuery Prototype + Scriptaculous YUI Ex
This file is part of the first edition of Eloquent JavaScript. Consider reading the third edition instead.
CSSgallery.info Javascript form validators When we use forms, we need somehow to validate the data user input. JavaScript製のフォームバリデータライブラリがいろいろ紹介されています。 Realtime validation using Ajax ( フォームの入力値をリアルタイムにバリデーション「Realtime validation」 ) LiveValidation ( JavaScriptでリアルタイム値チェックを簡単に行える「LiveValidation」 ) JSValidate ( prototype.jsベースのリアルタイムバリデートJSライブラリ「JSValidate」 ) validator.js - Client-side form validatin
The PBwiki engineering teamのメンバーがWebブラウザとJavaScriptライブラリのパフォーマンスを調査するために興味深いパフォーマンステストサイトを公開している。Javascript Library Performance Test Roundupにアクセスして"Run (West Coast)"かまたは"Run (East Coast)"をクリックしてみてほしい。使っているWebブラウザにおいてDojo 1.0.1、jQuery 1.2.1、Prototype 1.6.0、YUI 2.4.0、Protoculous 1.0.2の読み込み時間がどうなるかを調査してくれる。 しかも読み込み方法は通常のJavaScriptソースコード、キャッシュされたものとそうでないもの、Gzipで圧縮されたものとそうでないもの、YUI Compressorで最小化されたものと
Lightview Lightview was built to change the way you overlay images on a website. カスタマイズできる多機能LightBox「Lightview」。 次のように、背景色を赤にカスタマイズしたりできるLightBoxの登場です。 背景色のほか、角丸の度合いや、灰色背景の描画ON/OFFとその透明度、zIndex、表示の際のエフェクトなどをカスタマイズ可能です。 インストールは、必要なCSS/JSを読み込んだ後、<img> タグの rel 属性に lightview を設定するだけ。 (例: <a href='image.jpg' rel='lightview'>My image<a/> ) スライドショーの機能なんかも実装されています。 関連エントリ LightBox風に角丸で可愛く画像をポップアップしてくれる「F
今回はJavaScriptとWebページの表示・操作の体感速度について考えてみます。というのは,JavaScriptのせいでWebページの表示や操作などの速度が遅くなっている,と感じることがあるからです。 現在のWebサイトでは,JavaScriptを使って使い勝手を向上することは,ごく当たり前に行われています。例えば,動的にページを書き換えたり,ページ遷移を行わずにサーバーと通信を行ってデータを取得したりと,JavaScriptを使うことで,Webサイトをより便利に,より使いやすくすることができます。 Ajaxという言葉がはやってから,もう2年以上がたつんですよね。何年か前,JavaScriptはじゃまで,セキュリティを低下させる不要なものだと見なされていた頃がありました。しかしそれから一変して,「JavaScriptをがんがん使ってもいい」という空気になったことで,Webサイトを作成す
Ajaxパワーの活用方法 Ajaxは、ウェブアプリケーションの開発方法や利用方法を大きく変えた破壊的な技術だ。Ajaxによってインタラクティブなページの作成が可能になったのである。Ajaxは現在もウェブの流行の最先端を走り続けている。 Ajaxという用語は比較的最近生まれたものだが、Ajaxを支えている技術は以前から存在していた。ブラウザに送られたウェブページの内容をあとから変更する機能自体は、何年も前からあったのである。たとえば、JavaScriptでiframeのsrc属性を変更するのもそのような技術の一つだ。 しかし、XMLHttpRequestオブジェクトが主要なブラウザで実装され、GmailやGoogle Mapsが公開され始めると、開発者はそれをきっかけとしてウェブページの構築方法をもう一度考えるようになったのである。 XMLHttpRequestオブジェクト Ajaxを可能に
ZAPA氏の記事。 ニュータイプなJSライブラリjQueryを使ってみよう! これを見てから3日間。 ブログもあまりかけずこればっかりいじって遊んでました。 睡眠時間も1日2時間くらいになり、今日は書こうと思います。 まずZAPA氏、きっかけをありがとう。 私はJavaScriptの知識がほぼ皆無な人間です。 そんな私でもjQueryは簡単に使える為、面白くてはまりました。 ただ、お恥ずかしい話、PHPを使ってJavaScriptをある程度制御しなければ私は使いこなせません。 ですが恐ろしく簡単にこれまでこのブログで紹介してきたようなJavaScriptアプリと同等のものを作れる為、これははまります。 JavaScriptダメダメの私でも出来ました データベース接続部や、なんやかんやは全てPHPでまかない、動作部分やFormなどはjQueryに投げる。 こんな方法で色々試して見ましたが、A
JavaScriptライブラリのニュータイプ「jQuery」。 jQuery is a new type of JavaScript library. jQuery: The Write Less, Do More, JavaScript Library ニュータイプと聞いては黙っていられないニュータイプファンの皆様こんにちは、公開APIを利用したサンプルサイトを作っていくよ管理人のZAPAです。 Web2.0やらAjaxやらの言葉が流行っていても、実際にそれっぽいものを作ろうと思ったところで、初心者は一体どこから手を付けて良いのかわからないのが現実だったりします。 そこで今回は、Web2.0っぽくAjaxを実現させることができるライブラリ「jQuery」の紹介をします。 Ajaxとは ここで言うAjaxは、オランダの名門フットボールチーム「アヤックス」ではなく、ウェブブラウザ内で非同期通
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く