でも昔書いたのだけども、IE8以下ではopacityに対応していないので、jQueryでアニメーションしようとすると、色々なことが面倒。そこで、ばっさりIE8以下対応をさっさとやるのが以下。どうのこうのでブラウザ判別でもして
でも昔書いたのだけども、IE8以下ではopacityに対応していないので、jQueryでアニメーションしようとすると、色々なことが面倒。そこで、ばっさりIE8以下対応をさっさとやるのが以下。どうのこうのでブラウザ判別でもして
jQueryは互換性を保ちつつも洗練されたAPIを取り入れているので、新しく書くときは新しいAPIを使った方が良い。 liveとかセレクタの:hoverとかはBad Partsだ。 jQuery.fn.on / jQuery.fn.off live/delegate/bind/click等は滅びた。全てonを使おう。 また、data引数を使う場合は必ずdataをオブジェクトかnullにする。dataが文字列の場合、関数の場合にセレクタ等と区別がつかないからだ。 $("body").on("click", function (event) { alert("Clicked!"); }, false); また、querySelector/querySelectorAllの登場によって、:hover等のjQuery固有のセレクタは滅びた。validなCSSセレクタと、jQueryのメソッドをch
HTML5をサポートしていないIE6〜IE8で、node.innerHTML = " ..."; のように HTML5 で追加された新要素含んだ文字列を innerHTML に与えると、次のいずれかの条件が成立した場合に親子関係の崩れたサブツリーを生成してしまいます。 innerHTML の前に document.createElement() が実行されていない node が DOM Tree に参加していない(オンザフライ) これらを回避するには、IE6〜IE8で以下のようします。 document.createElement("section"); // HTML5 Shiv function build(fragment) { // @param HTMLDocumentFragmentString: "<nav>...</nav>" // @return DocumentFrag
2010/12/10 コース:元祖こってり 「元祖こってり」記事はネットエージェント旧ブログ[netagent-blog.jp]に掲載されていた記事であり、現在ネットエージェントに在籍していないライターの記事も含みます。 IE8+jQueryによるクロスドメイン通信とXDomainRequestラッパーの作成 こんにちは、ネットエージェント株式会社、研究開発部の長谷川です。 さっそくですが、みなさんは「Advent Calendar」をご存じでしょうか? Advent Calendar と言えば、一般的には、クリスマス(12月25日)までの残り日数をカウントダウンするカレンダーを思い浮かべるかもしれませんが、ここで紹介する Advent Calendar とは、様々な業界、技術方面で活躍されているプログラマ有志が、毎日交代で1つずつ技術的なトピックスを紹介する技術系Webイベントのことです
step1: 動けばいいレベル 適当にざっくり書いて終了 イベントハンドラのなかでテキトーに全て終わらせる メソッドチェイン長いのがかっこいいと思ってる年頃 <div class="item"> <div class="label">A</div> <h2 class="title">itemA</h2> <p class="main">text text text text</p> <p class="showMore">more</p> <p class="more">more more more more</p> <p class="hideMore">hide</p> </div> <div class="item"> <div class="label">B</div> <h2 class="title">itemB</h2> <p class="main">text text
I recently came across a jQuery plugin that claims to emulate the functionality of Object.prototype.watch, a method inherent in all objects that enables you to watch for a property change and run a function upon that change. Of course, this isn’t available in all implementations. IE, for example, doesn’t support this but has a DOM equivalent, onPropertyChange. Both methods are useful but their sli
Introduction This post continues to focus on areas where C# developers tend to make bad JavaScript decisions based on their previous training. The languages are similar enough syntactically that C# developers tend to not invest the time to learn JavaScript’s differences. The following post points out several misunderstandings that can get you into some confusing situations. Gaming PC Main Componen
Yesterday, Dan G. Switzer, II was giving me some really great jQuery tips. Among the things that we discussed was the ability to define an anonymous function and then call it immediately: This is not jQuery specific, but the benefits of doing this is that you can create a totally private memory space in which to execute your anonymous function. In this memory space, locally declared variables won'
$(‘hoge’).css(‘backgroundPosition’)だとIEで値が取れないんですね、不便か。 XとYを別々に取得したい 値の検証 var bgPosDef = $('#hoge').css('backgroundPosition'); IE8まで(9は未検証) console: null(空) Firefox, Chrome, Safari, Operaなど console: 50px 50px IEは返されるデータがない!こういうところがみんなが嫌いな所以ですかね。IEはbackgroundPositionではなくて、backgroundPositionXのようにXかYを指定して個別に引き抜きます。 var bgPosX = $('#hoge').css('backgroundPositionX'); var bgPosY = $('#hoge').css('backg
jQueryでは非DOMオブジェクトにもeventをbind/triggerできる Binding Events To Non-DOM Objects With jQuery この例だとwindow.location.hrefが変化しているかどうかTimerで監視し続け、 変化したタイミングで$( window.location ).trigger('change',data);で変更前後の情報を通知している。 なので、$( window.location ).bind('change',function(ev,data){});で通知を受け取る事ができる。 hashで状態を管理しているAjaxアプリで有効そうなテクニック。 select boxでcustom eventを活用 http://trulyevil.com/2009/05/07/custom-events-in-jquery/
*WordPressプラグインもあります Greasemonkeyで有名なAutoPagerize、最近ははてなブックマークでも取り入れられて 機能としてサイト側でやるものかどうかっていう話も聞いたりしました。 AutoPagerizeは一度使ったらもう手放せないくらい便利ですけど これを自分でやってみました。 使い方は簡単、 5509内 ホーム・カテゴリ・タグ・検索のいずれかのページで、ページナビゲーションがある場合 ページナビゲーションにカーソルが近付くと自動で次のページを読み込んで下に追加表示します。 ひとつだけ出来なかったところがあって AutoPagerizeで読み込んだ部分はが適用できてないです。。解決、追記しました ソース(ログ) // AutoPagerize if($("div.wp-pagenavi","#main").length>0){ // WP-PageNavi
In my last two tutorials, I explained how to use event delegation for showing and hiding tooltips. In a comment on the first one, Jan Aagaard asked how we might go about enhancing the script by adding a small delay before showing a tooltip. The answer lies with two JavaScript functions, setTimeout() and clearTimeout(). Setting Up Picking up where we left off last time, I’m going to create the tool
当ブログの中の人による海外旅行写真サイトで、jQueryのPlug-inを利用した画像の遅延ロードを試してみました。 使用したプラグインは、Lazy Load (Lazy Load Plugin for jQuery)。 このプラグイン、プレースホルダーとして使用する画像...当ブログの中の人による海外旅行写真サイトで、jQueryのPlug-inを利用した画像の遅延ロードを試してみました。 使用したプラグインは、Lazy Load (Lazy Load Plugin for jQuery)。 このプラグイン、プレースホルダーとして使用する画像のサイズを指定することができないため、プレースホルダー画像がロードする画像と同じサイズで表示されてしまいます。これだと色々なサイズの画像があるページでローディングアニメーションを表示させるのに都合が悪いため、少々手を入れました。元にしたバージョンは
Last time I showed how to use event delegation to create a simple tooltip for a huge number of elements without running into the problem of binding an event handler to all of those elements. In this tutorial, I’m going to refine that tooltip script a bit, avoiding some code repetition and fixing a bug that someone pointed out in a comment. For review, here is the final version of the script from t
Track Downloads and Other Click Events in Analytics with jQuery The old way to track clicks and outbound links in Google Analytics was to call the _trackPageview function on the click event, passing it a label that could then be searched for in Analytics. One of the problems with this method was that the clicks were counted as pageviews, affecting your total pageview number. Now Analytics offers a
DBにあるデータをランダムに取得する処理をjQuery.ajaxで書いたところ、Firefox(多分ヤツ以外は)ではうまくいくけど、IEだけは常に同じデータを取得してくるという問題に遭遇。 どーせヤツのことだ、ググれば答えは一発で出てきた。 どうやらIEはXmlHttpRequestの結果をキャッシュするらしい。 そして、それを防ぐためには$.ajax()の前に下記を追加すればいいとのこと。 $.ajaxSetup({ cache: false }); 参考サイト IEがajaxキャッシュするのを抑制 – はらぐろブログラマン 大変助かりました。ありがとうございます! 余談ですが・・・ 僕のまわりでは、もうMSはブラウザを作らなければいいのにってみんな言ってます。 素晴らしいブラウザは他にたくさんあるんだから、OS作りに全精力傾けて欲しいものです。。。
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く