Re: copy annoyance fix

From: Date: Sat, 14 Sep 2002 22:15:35 +0000
Subject: Re: copy annoyance fix
References: 1 2 3 4 5  Groups: php.doc.chm 
Request: Send a blank email to php-doc-chm+get-512@lists.php.net to get a copy of this message
> this is the last bloody time I look at this copy feature! > > any way, I think I found a solution that will work with ie4+ and will not > cause ie5.0-5.1 to occasionally crash on select operating systems. oah ya... > and the bug that we were experiencing earlier. > > take a look, the only thing I changed was copyExample() > > no I didn't change the selection copy, I cant get the right click menu to > work for the life of me. any way, it shouldn't be hard for someone else to > implement. > > the link is http://knightsweb.net/_script.zip OK, so just talk about this a bit before applying any fix (I won't release a new sample just because of this issue). You used this code: BodyRange = document.body.createTextRange(); BodyRange.moveToElementText( document.body.all['example_' + number]); BodyRange.execCommand( "Copy" ); if (document.selection && window.clipboardData) { window.clipboardData.setData("Text", document.all['example_' + number].innerText); } else { alert("Example copy won't work with this browser"); } This tries to find out if there is any incompatibility. clipboardData is actually supported since IE5, so older browsers will only print out the alert. Otherwise from the code there should be no problem, as innertext for <code>s is available since 4.0. It may be buggy though... Your code simply tries to use textranges, with wich the moveToElementText is only available since 5.0, so the lowest IE version needed is still IE5. Have you tested this, and found that it works for you? Then so maybe if we spice it up with some compatibility tests, it would work... Goba

« previous php.doc.chm (#512) next »