Menu

#9 Internet Explorer - Copy/Cut & Paste Fix

open
nobody
None
5
2008-06-21
2008-06-21
typhos_j
No

Hi,
I fixed the copy/cut & paste problem in internet explorer. It's tested in IE7 only at this moment.

1. Change the copy-part of the keyHandler function to this:

else if((keyCode==67 || keyCode == 88) && evt.ctrlKey) { // handle copy and cut

sel = document.selection.createRange();
copy = sel.htmlText;
copy = copy.replace(/<\/P><P>/gi, '\r\n');
copy = copy.replace(/<.*?>/g, '');
copy = copy.replace(/&lt;/g, '<');
copy = copy.replace(/&gt;/g, '>');

window.clipboardData.setData('text', copy);

if (keyCode == 88)
document.selection.clear();
evt.returnValue = false;
}

2. Change the line

o = o.replace(/&nbsp;/g,'');

in function syntaxHighlight to this one:

o = o.replace(/&nbsp;/g,' ');

Discussion

  • typhos_j

    typhos_j - 2008-06-23

    Logged In: YES
    user_id=1992325
    Originator: YES

    A little mistake: The first change is NOT in the keyHandler function, but in the metaHandler function!
    Sorry...

     
  • matt-editme

    matt-editme - 2008-08-06

    Logged In: YES
    user_id=1308806
    Originator: NO

    In case you're having trouble finding where this code goes, it's in the codepress/engines/msie.js file.

     

Log in to post a comment.