ページの一部にダブルクリックが必要な場合があります。これは、ユーザーが誤ってページのテキストの一部を強調表示するという望ましくない影響を与えます。HTMLテキストのハイライト表示を停止する
これは実際には完璧ではありませんが、テキストの代わりに画像を使用する以外に、これをやめるためのきれいな方法がありますか?
ありがとうございます。
ページの一部にダブルクリックが必要な場合があります。これは、ユーザーが誤ってページのテキストの一部を強調表示するという望ましくない影響を与えます。HTMLテキストのハイライト表示を停止する
これは実際には完璧ではありませんが、テキストの代わりに画像を使用する以外に、これをやめるためのきれいな方法がありますか?
ありがとうございます。
ここでは、cssはテキストの選択を無効にします。 @arunesが示唆したように How to disable text selection highlighting using CSS?
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
、あなたはほとんどのブラウザのためのCSSでこれを行うことができます。しかし、私はこれがIE 6-8(少なくとも)では動作しないことを読んだことがあります。そのために、あなたのようなものが必要になる場合がありますので:
document.getElementById("divDoubleClick").onselectstart = function() { return false; };
をこれが私の作品
としてフォームフィールド内の選択を可能にするためにも、これらを追加
body, div
{
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: -moz-none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
}
にCSSスタイルを置くことを提案
input, textarea, .userselecton
{
-webkit-touch-callout: text;
-webkit-user-select: text;
-khtml-user-select: text;
-moz-user-select: text;
-ms-user-select: text;
-o-user-select: text;
user-select: text;
}
入力が機能しないために必要な-moz-noneが必要であるか、reenableに注意してください。 IE用
私は
<script type="text/javascript">
window.addEvent("domready", function()
{
document.addEvent("selectstart", function(e)
{
if ((e.target.tagName == "INPUT") ||
(e.target.tagName == "TEXTAREA") ||
(e.target.hasClass("userselecton")))
{
return true;
}
return false;
});
});
</script>
を追加これは、バックグラウンドテキストの選択を防ぐだけでなく、あなたが上userseletonクラスを入れinputfieldsとし、要素に選択することができます。
おかげで有益な情報! – CompanyDroneFromSector7G
私にとっては十分です!ありがとう:) – CompanyDroneFromSector7G
なぜあなたは-webkit-touch-callout:none;を追加しましたか? –