[過去ログ] + JavaScript の質問用スレッド vol.84 + (1001レス)
前次1-
抽出解除 レス栞

このスレッドは過去ログ倉庫に格納されています。
次スレ検索 歴削→次スレ 栞削→次スレ 過去ログメニュー
152
(3): 2011/03/01(火)16:33 ID:??? AAS
IE8で、thisの指す内容を無理やり書き換えることは出来ませんか

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja">
<head>
<title>foobar</title>
</head>
<body>

<div id="foobar">foobar</div>

<script type="text/ecmascript">
省8
153
(1): 2011/03/01(火)16:36 ID:??? AAS
>>152
Function.prototype.call を使えば出来る。
156
(1): 152 2011/03/01(火)17:46 ID:??? AAS
>>153
ありがとうございます。上手くいきました

var foobar = document.getElementById('foobar');
foobar.attachEvent('onclick', function(){(function(){
this.firstChild.data = 'IE';
}).call(event.srcElement)});
159
(2): 152 2011/03/01(火)18:41 ID:??? AAS
>>157-158
すみません。実際に使わせて戴いた部分は>>158の通りです

Element.prototype.addEventListener = function(type, listener, useCapture){
var target = this;
target.attachEvent('on' + type, function(){
listener.call(target, event);
});
};
前次1-
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル

ぬこの手 ぬこTOP 0.219s*