JS, 클립보드로 컨텐트 복사(IE & Photo 호환)
3751 단어 IE
<script>
function CopyText(id)
{
//copyToClipboard(document.getElementById(id).value);
copy(document.getElementById(id).value);
}
function copy(text2copy) {
if (window.clipboardData) {
window.clipboardData.setData("Text",text2copy);
} else {
var flashcopier = 'flashcopier';
if(!document.getElementById(flashcopier)) {
var divholder = document.createElement('div');
divholder.id = flashcopier;
document.body.appendChild(divholder);
}
document.getElementById(flashcopier).innerHTML = '';
var divinfo = '<embed src="_clipboard.swf" FlashVars="clipboard='+escape(text2copy)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';//
document.getElementById(flashcopier).innerHTML = divinfo;
alert('Text copied');
}
}
function copyToClipboard(meintext)
{
if (window.clipboardData){
//alert("ie");
// the IE-manier
window.clipboardData.setData("Text", meintext);
// waarschijnlijk niet de beste manier om Moz/NS te detecteren;
// het is mij echter onbekend vanaf welke versie dit precies werkt:
}
else if (window.netscape){
// dit is belangrijk maar staat nergens duidelijk vermeld:
// you have to sign the code to enable this, or see notes below
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
} catch (e) {
alert(" !"); } //
'about:config'
'signed.applets.codebase_principal_support' 'true'
// maak een interface naar het clipboard
var clip = Components.classes['@mozilla.org/widget/clipboard;1'].
createInstance(Components.interfaces.nsIClipboard);
if (!clip) return;
//alert("mozilla");
// maak een transferable
var trans = Components.classes['@mozilla.org/widget/transferable;1'].
createInstance(Components.interfaces.nsITransferable);
if (!trans) return;
// specificeer wat voor soort data we op willen halen; text in dit geval
trans.addDataFlavor('text/unicode');
// om de data uit de transferable te halen hebben we 2 nieuwe objecten
// nodig om het in op te slaan
var str = new Object();
var len = new Object();
var str = Components.classes["@mozilla.org/supports-string;1"].
createInstance(Components.interfaces.nsISupportsString);
var copytext=meintext;
str.data=copytext;
trans.setTransferData("text/unicode",str,copytext.length*2);
var clipid=Components.interfaces.nsIClipboard;
if (!clip) return false;
clip.setData(trans,null,clipid.kGlobalClipboard);
}
alert(" :" + meintext);
return false;
}
</script>
copyToClipboard(meintext);
meintext 。
<input id='a' name='a' type='text'value='good' />
<input name="" type="button" value=' ' onClick="copyToClipboard(a.value)">
<a href="ums://aHR0cDovLzMyLmRjLmZ0bi5xcS5jb20vZnRuX2hhbmRsZXIvY2E1NGY4YzE3NTI5MzNiNzQ2NjU5ZmVmZjliNTUwZTM0NWNkMTVhNDg1Nzc4ODg5N2MxMWUyMjcwZDE3YjcxMGMwZGUxMmJlMGEyZTVhM2E1MTExMmE1Y2FlOTNmYjkwMGIxNmFkZWVjOGZiYmMxNThlNzg1YTRmNWRjMDdmZGIvQkJDJUU4JTkzJTlEJUU4JTg5JUIyJUU2JTk4JTlGJUU3JTkwJTgzMDgucmFyJjhjZDA3ZTUz" onClick="copyToClipboard(this.href)">01 </a>
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
KindEditor 4.1.2 ie6 loadScript bugKindEditor 버전 4.1.2 ie6 아래_loadScript 메소드 버그 소스 코드는 다음과 같습니다. 이 세그먼트 코드를 다음 코드로 변경하면 정상적으로 실행됩니다....
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.