2012-01-26 11 views
1

私たちのASPXサイトでは、DEVExpressをIE 8(オリジナルのものでIE IE 8ではなくIE 9)ログインページに我々は常にエラーしている:ASPXとDEVExpressでIE 8のJS focus()メソッドをオーバーライドします...

Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus. 

だから - 私が研究し、何かが見えない何かに集中しようとしていることが分かりました。だから私はfocus()メソッドをオーバーライドしてこのソリューションを試しました。以下に、短いサンプルHTMLページを示します。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
    <head> 
    <title>AccuLynx</title> 
    <script type="text/javascript"> 
     HTMLInputElement.prototype.focusCpy = HTMLInputElement.prototype.focus; 
     HTMLInputElement.prototype.focus = function() { 
     if(this.style.display != 'none' && this.style.visibility != 'hidden' && !this.disabled && this.type != 'hidden') { 
      HTMLInputElement.prototype.focusCpy.apply(this, arguments); 
     } 
     } 
    </script> 
    </head> 
    <body> 
    <input type="submit" id="my_link" style="display:none;" value="dfsdfd" /> 
    <script type="text/javascript"> 
     document.getElementById('my_link').focus(); 
    </script> 
    </body> 
</html> 

そして、テストページでは、実際のサイトではすべてが正常に見えますが、そうではありません。

JSコードは、2番目のJSファイルの先頭(最初はJQueryプラグイン)で実行される最初のものの1つですが、動作しません。

アドバイスありがとうございます。

+0

私はまずフォーカスステートメントを発行し、これが発生しないようにするコードを見つけようとします。これが不可能な場合は、エラーを処理して、許容範囲内にフォーカスを設定してみてください。 –

+0

それは奇妙な問題です。 DXに連絡して修正を依頼する方がよいでしょう。 – Mikhail

答えて

3

私はこの1つにJSコードを変更... :)解決策を見つけた:

HTMLInputElement.prototype.focusCpy = HTMLInputElement.prototype.focus; 
    HTMLInputElement.prototype.focus = function() { 
    if(this.style.display != 'none' && this.style.visibility != 'hidden' && !this.disabled && this.type != 'hidden' && this.style.width != '0px' && this.style.width != '0%' && this.style.width != 0) { 
     HTMLInputElement.prototype.focusCpy.apply(this, arguments); 
    } 
    } 

や他の言葉で - 私は、私が覚えていくつかの時間後に原因を要素の幅のチェックを追加しましたこのばかげたブラウザ - IE - は、しばしば幅と高さが0pxの要素をレンダリングします。

これは動作します:)

+0

DIVの幅が0であるため、DevExpressのポップアップコントロールにも同様の問題がありました。この回答はIE8の動作を修正するのに役立ちました。 –

+0

このソリューションを試してみましたが、ローカルマシンでうまく動作しますが、サーバーにデプロイした後、** 'HTMLInputElement'が未定義**というエラーが表示されます。何が問題なの? –

+0

これを試しているInternet Explorerは何ですか? ... :) ... –

関連する問題