Hirdetés
- Nem csak drága ATX 3.1-es tápok léteznek
- Házimozi belépő szinten
- Kormányok / autós szimulátorok topikja
- Apple MacBook
- AMD Ryzen 9 / 7 / 5 9***(X) "Zen 5" (AM5)
- Canon MILC: EOS R és M topik
- Fejhallgató erősítő és DAC topik
- NVIDIA GeForce RTX 5080 / 5090 (GB203 / 202)
- AMD Ryzen 9 / 7 / 5 7***(X) "Zen 4" (AM5)
- Vezetékes FEJhallgatók
-
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
- PlayStation 5
- Samsung Galaxy Z Fold7 - ezt vártuk, de…
- Poco F6 5G - Turbó Rudi
- Akciófigyelő: Jelentős kedvezményekkel veheted meg a Xiaomi 17-eket
- Nem csak drága ATX 3.1-es tápok léteznek
- Házimozi belépő szinten
- Milyen légkondit a lakásba?
- Garancia kérdés, fogyasztóvédelem
- Revolut
- Xiaomi 13T és 13T Pro - nincs tétlenkedés
- További aktív témák...
- Samsung Odyssey G9 S49CG954EU 5120x1440 / VA / 240hz
- BESZÁMÍTÁS! Akár részletfizetés 0% THM ÚJ AMD RYZEN AM4 processzorok 3 év garanciával 27% áfaval
- Samsung Galaxy S22 Ultra 256GB, Kártyafüggetlen, 1 Év Garanciával
- Macbook Pro 13" 2019 - 4 mag i5, 8GB RAM, touchbar - garancia (13)
- DJI Flip Fly More Combo (RC 2)
- Apple iPhone 15Pro 128GB - Kártyafüggetlen, Fekete Titán, 85% Akku - 1év Garanciával
- BESZÁMÍTÁS! Inno3D iChill X3 RTX 3080 Ti 12GB videokártya garanciával hibátlan működéssel
- HP Z420 Workstation,Xeon E5-1620 CPU,8GB RAM,500GB SATA3 HDD,WIN10
- BESZÁMÍTÁS! MSI B760M i7 13700KF 32GB DDR5 1TB SSD RX 7800 XT 16GB Lian LI LANCOOL 207RX ADATA 750W
- Apple iPhone 15 128GB, Kártyafüggetlen, 1 Év Garanciával
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest

