I have little problem with copying text. On my website color of the font is set to white:
我对复制文本没什么问题。在我的网站上,字体颜色设置为白色:
body {
color: #FFF;
}
Exmaple:
例子:
When I copy for example "List of programs" and I want paste it to Word, Lync text is white. Is it possible to add some styles/js which change this color to black in external programs? I know in word is paste option "Keep text only" but what with Lync?
当我复制“程序列表”时,我想把它粘贴到Word中,Lync文本是白色的。是否有可能添加一些样式/js,在外部程序中将这种颜色改为黑色?我知道在word中粘贴选项“只保留文本”,但是Lync呢?
@Update
@Update
That javascript works almost I expected. Problem is with IE. Any idea?(tested on chrome 45.0.2454.101)
javascript几乎可以正常工作。问题是与IE。任何想法?(铬45.0.2454.101测试)
(function (container, defaultColor, copyColor) {
selectedText = window.getSelection();
$(container).keydown(function (e) {
e = e || window.event;
var key = e.which || e.keyCode;
var ctrl = e.ctrlKey ? e.ctrlKey : ((key === 17) ? true : false);
if (key == 67 && ctrl) {
var range = getRange(selectedText);
changeColor(range, selectedText, copyColor);
}
}).keyup(function (e) {
var range = getRange(selectedText);
if (range) {
selectedText.removeAllRanges();
selectedText.addRange(range);
}
changeColor(range, selectedText, defaultColor);
});
function getRange(text) {
if (text.rangeCount && text.getRangeAt) {
return text.getRangeAt(0);
}
return null;
}
function changeColor(range, selectedText, color) {
document.designMode = "on";
if (range) {
selectedText.removeAllRanges();
selectedText.addRange(range);
}
document.execCommand("ForeColor", false, color);
document.designMode = "off";
}
})("body", "white", "black");
6 个解决方案
#1
2
You can copy paste the link from anywhere, then in your Microsoft word select the text that you have pasted and then right-click -> paste options -> merge formatting. I think this would solve your problem.
你可以从任何地方复制粘贴链接,然后在你的Microsoft word中选择你粘贴的文本,然后右击->粘贴选项->合并格式。我想这能解决你的问题。
#2
1
You can reset text while selecting as follows:
你可以在选择时重置文本如下:
p.reset_selection {
color: #FFF;
background-color: #31727E;
padding: 15px;
}
p.reset_selection::-moz-selection {
background-color: #FFF;
color: #000;
}
p.reset_selection::selection {
background-color: #FFF;
color: #000;
}
<p class="reset_selection">List of programs</p>
Or you can paste text in Lync using Ctrl+Shift+V
或者你可以在Lync中使用Ctrl+Shift+V粘贴文本。
Or you can try PureText using which you can configure a hotkey like Win+V
to paste text only without any styling.
或者你可以尝试使用PureText来配置一个热键,比如Win+V,只在没有任何样式的情况下粘贴文本。
#3
0
To get color of copied text as black, you have to add following css to your code:
要想让复制的文本颜色为黑色,必须在代码中添加以下css:
::-moz-selection { /* For Firefox */
color: #000;
}
::selection {
color: #000;
}
It will change the color of the text you are selecting to #000 i.e., black and the text then you copied have black color.
它会改变你选择的文本的颜色,即#000。,黑色和文本,然后你复制的是黑色。
#4
0
I believe you are looking for ::selection
. You can use it to set the color of the text or the background of the selected area (default is blue in chrome and some other browsers :-) )
我相信你在寻找::选择。您可以使用它来设置文本的颜色或选定区域的背景(默认为蓝色和其他一些浏览器:-))
#5
0
::-moz-selection {
background-color: #FFA;
color: #000;
}
/* Works in Safari */
::selection {
background-color: #FFA;
color: #000;
}
#6
0
This code solved my problem.
这段代码解决了我的问题。
window.onload = function () {
document.addEventListener('copy', function (e) {
selectedText = window.getSelection().toString();
if (window.clipboardData) {
window.clipboardData.setData("Text", selectedText);
} else {
e.clipboardData.setData('text/plain', selectedText);
}
e.preventDefault();
});}
#1
2
You can copy paste the link from anywhere, then in your Microsoft word select the text that you have pasted and then right-click -> paste options -> merge formatting. I think this would solve your problem.
你可以从任何地方复制粘贴链接,然后在你的Microsoft word中选择你粘贴的文本,然后右击->粘贴选项->合并格式。我想这能解决你的问题。
#2
1
You can reset text while selecting as follows:
你可以在选择时重置文本如下:
p.reset_selection {
color: #FFF;
background-color: #31727E;
padding: 15px;
}
p.reset_selection::-moz-selection {
background-color: #FFF;
color: #000;
}
p.reset_selection::selection {
background-color: #FFF;
color: #000;
}
<p class="reset_selection">List of programs</p>
Or you can paste text in Lync using Ctrl+Shift+V
或者你可以在Lync中使用Ctrl+Shift+V粘贴文本。
Or you can try PureText using which you can configure a hotkey like Win+V
to paste text only without any styling.
或者你可以尝试使用PureText来配置一个热键,比如Win+V,只在没有任何样式的情况下粘贴文本。
#3
0
To get color of copied text as black, you have to add following css to your code:
要想让复制的文本颜色为黑色,必须在代码中添加以下css:
::-moz-selection { /* For Firefox */
color: #000;
}
::selection {
color: #000;
}
It will change the color of the text you are selecting to #000 i.e., black and the text then you copied have black color.
它会改变你选择的文本的颜色,即#000。,黑色和文本,然后你复制的是黑色。
#4
0
I believe you are looking for ::selection
. You can use it to set the color of the text or the background of the selected area (default is blue in chrome and some other browsers :-) )
我相信你在寻找::选择。您可以使用它来设置文本的颜色或选定区域的背景(默认为蓝色和其他一些浏览器:-))
#5
0
::-moz-selection {
background-color: #FFA;
color: #000;
}
/* Works in Safari */
::selection {
background-color: #FFA;
color: #000;
}
#6
0
This code solved my problem.
这段代码解决了我的问题。
window.onload = function () {
document.addEventListener('copy', function (e) {
selectedText = window.getSelection().toString();
if (window.clipboardData) {
window.clipboardData.setData("Text", selectedText);
} else {
e.clipboardData.setData('text/plain', selectedText);
}
e.preventDefault();
});}