- Épített vízhűtés (nem kompakt) topic
- AMD Ryzen 9 / 7 / 5 9***(X) "Zen 5" (AM5)
- Kormányok / autós szimulátorok topikja
- Fejhallgató erősítő és DAC topik
- Akciókamerák
- Milyen videókártyát?
- Házi barkács, gányolás, tákolás, megdöbbentő gépek!
- Felvenné a Noctua kesztyűjét az ASUS
- Utánajártunk, hogy melyik memória mennyire drágulhat
- Intel Core Ultra 3, Core Ultra 5, Ultra 7, Ultra 9 "Arrow Lake" LGA 1851
-
PROHARDVER!
JavaScript != Java (A JavaScript nem összekeverendő a Javával, két különböző programozási nyelvről van szó!)
Új hozzászólás Aktív témák
-
btz
addikt
Ezt próbálgattam már. Nálam nem működik (szokás szerint)
Először így próbáltam:
<script type="text/javascript" >
// Create a fake textarea
const textAreaEle = document.createElement('textarea');
// Reset styles
textAreaEle.style.border = '0';
textAreaEle.style.padding = '0';
textAreaEle.style.margin = '0';
// Set the absolute position
// User won't see the element
textAreaEle.style.position = 'absolute';
textAreaEle.style.left = '-9999px';
textAreaEle.style.top = `0px`;
// Set the value
textAreaEle.value = text;
// Append the textarea to body
document.body.appendChild(textAreaEle);
// Focus and select the text
textAreaEle.focus();
textAreaEle.select();
// Execute the "copy" command
try {
document.execCommand('copy');
} catch (err) {
// Unable to copy
} finally {
// Remove the textarea
document.body.removeChild(textAreaEle);
}
</script>Ekkor a textAreaEle.value = text; érték nem volt definiálva így készítettem neki egy változót. var text = "tesztszöveg";
<script type="text/javascript" >
// Create a fake textarea
const textAreaEle = document.createElement('textarea');
// Reset styles
textAreaEle.style.border = '0';
textAreaEle.style.padding = '0';
textAreaEle.style.margin = '0';
// Set the absolute position
// User won't see the element
textAreaEle.style.position = 'absolute';
textAreaEle.style.left = '-9999px';
textAreaEle.style.top = `0px`;
var text = "tesztszöveg";
// Set the value
textAreaEle.value = text;
// Append the textarea to body
document.body.appendChild(textAreaEle);
// Focus and select the text
textAreaEle.focus();
textAreaEle.select();
// Execute the "copy" command
try {
document.execCommand('copy');
} catch (err) {
// Unable to copy
} finally {
// Remove the textarea
document.body.removeChild(textAreaEle);
}
</script>Hiba: Uncaught TypeError: Cannot read property 'appendChild' of null.
Beraktam bodyba a scriptet, utána semmit nem csinált, viszont a hiba megszűnt.
Aztán a document.body részt cseréltem document.getElementById("mainContent").appendChild(textAreaEle);-re. Így már megjelenik a textarea, benne a tesztszöveg felirattal. (A kódból kitöröltem azt a részt ami elrejti a textarea-t).<html>
<body>
<div id="mainContent">
MAIN CONTENT<br />
</div>
<script type="text/javascript" >
// Create a fake textarea
const textAreaEle = document.createElement('textarea');
var text = "tesztszöveg";
// Set the value
textAreaEle.value = text;
// Append the textarea to body
document.getElementById("mainContent").appendChild(textAreaEle);
// Focus and select the text
textAreaEle.focus();
textAreaEle.select();
// Execute the "copy" command
try {
document.execCommand('copy');
} catch (err) {
// Unable to copy
} finally {
// Remove the textarea
//document.body.removeChild(textAreaEle);
}
</script>
</body>
<html>Viszont nem másol semmit a vágólapra.
Új hozzászólás Aktív témák
- Horgász topik
- Épített vízhűtés (nem kompakt) topic
- AMD Ryzen 9 / 7 / 5 9***(X) "Zen 5" (AM5)
- Teljes verziós játékok letöltése ingyen
- Huawei Watch GT 6 és GT 6 Pro duplateszt
- Kormányok / autós szimulátorok topikja
- Fejhallgató erősítő és DAC topik
- Akciókamerák
- exHWSW - Értünk mindenhez IS
- iPhone topik
- További aktív témák...
- Lenovo ThinkPad X13 G2 13.3" -50% AMD Ryzen 5 Pro 5650U Hexa-core 16GB 512GB SSD FHD
- Gaming PC - R5 9600X,RTX 5070 12GB,32GB DDR5,1TB NVMe,850W
- Ultra PC - R7 7800X3D,RTX 5080 16GB,32GB DDR5,1TB NVMe,1200W
- Uhh Lenovo ThinkPad P15 G2 Tervező Vágó Laptop -75% 15,6" i5-11500H 32/1TB RTX A2000 4GB /1 Millió/
- Lenovo Legion 5 15ARH05H - Gamer Laptop
- Akciós Windows 10 pro + Office 2019 professional plus csomag AZONNALI SZÁLLÍTÁS
- 3DKRAFT.HU - 3D NYOMTATÁS - AZONNALI ÁRAJÁNLAT - GYORS KIVITELEZÉS - 500+ POZITÍV ÉRTÉKELÉS
- Dell 14 Latitude 7450 WUXGA 2in1 Touch X360 Ultra5 135U 12mag 16GB 512GB Win11 Pro WiFi7 Garancia
- BESZÁMÍTÁS! MSI B450M R5 5600X 32GB DDR4 512GB SSD RTX 3070 8GB Zalman Z1 PLUS Cooler Master 700W
- Dji Osmo Pocket 3 Creator combo
Állásajánlatok
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest
Cég: BroadBit Hungary Kft.
Város: Budakeszi


