Hallo,
ich habe in dem nachfolgenden Beispiel einen Text, der markiert werden soll.
Der Text befindet sich in einer Ebene, die per "margin:auto" horizontal zentriert ist.
In Firefox, Opera, IE 6,7,8 wird über meine Funktion exakt der Text markiert http://www.abload.de/image.php?img=firefoxmkuk.jpg.
In Chrome und Safari wird leider links und rechts darüber hinaus markiert, obwohl die Ebene in ihrer Breite genau definiert ist. http://www.abload.de/image.php?img=chromepmar.jpg
Hat jemand eine Ahnung, warum das so ist und ggf. eine Lösung ?
Mit Dank im Voraus Sebastian
P.S.: Doctype ist Xhtml Strict
Nachfolgend Css+Funktion+Body:
----------------------------------------------------------------------------
----------------------------------------------------------------------------
<style type="text/css">
<!--
*
{
padding:0px;
margin:0px;
}
-->
</style>
----------------------------------------------------------------------------
----------------------------------------------------------------------------
<script type="text/javascript">
<!--
var dom = (document.getElementById) ? 1:0;
//
function markiere_auswahl()
{
if (dom)
{
ebene = document.getElementById('ebene1');
if (document.selection)
{
auswahl = document.selection.createRange();
auswahl.moveToElementText(ebene);
auswahl.select();
}
if (window.getSelection)
{
auswahl = window.getSelection();
auswahl.selectAllChildren(ebene);
}
}
}
-->
</script>
----------------------------------------------------------------------------
----------------------------------------------------------------------------
<div id="ebenen" style="width:600px;margin:60px auto auto auto">
<div id="ebene1">
nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat,
vel illum dolore eu feugiat nulla facilisis at vero et accumsan et iusto odio dignissim qui
blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim
placerat facer possim assum.
</div>
<div>
<a href="javascript:markiere_auswahl()">Text markieren</a>
</div>
</div>
----------------------------------------------------------------------------
----------------------------------------------------------------------------