Note that there are some explanatory texts on larger screens.

plurals
  1. POPasting From MS-Word into any Browser-based HTML Editor
    text
    copied!<p>Ok, I can't be the only one with this problem that seems to go on forever and ever.</p> <p>We use browser-based html editors (a few different ones) - each one has its own 'paste-from-word' button that works great.</p> <p>However, many of our users just paste in directly from word into the design area. For us, this results in the end-of-the-world -- sometimes it breaks javascript or other things too numerous to mention.</p> <p>So, I have decided to write a simple function that searches the content of the source code, and if it sees any bad characters that are associated with a microsoft word paste, to throw back a match of 'this looks like a ms-word paste'. Currently, it looks like this:</p> <pre><code>// detect potentially bad characters - usually from msword paste function hasInvalidChars ( in_element ) { var src = $j(in_element).val(); var e = $E(src); // enhanced string var bad = Array( "mso-list:", "class=\"Mso", "&lt;/o:p&gt;", "[if !supportLists]", "style=\"mso-", "mso-bidi", "“", "”", "&lt;v:shapetype", "&lt;v:path", "file:///" ); for ( i=0; i&lt; bad.length; i++ ) { if ( e.contains(bad[i]) ) { return true; } } return false; } </code></pre> <p>Note that if you try running the code, it won't work because (1) i use jQuery and (2) i have a special object ( $E ) that adds a bunch of stuff to a string, one being a 'contains()' function, but you get the idea of what it's doing.</p> <p>What I am looking for are the array elements that belong in the 'bad[]' array. I have come up with a preliminary list (which may or may not be a good starting point), but I am asking you experts out there - please - can you tell me which characters or phrases you would put here? At this point, if I could catch 80% of the issues, I would be ecstatic.</p> <p>Thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload