Hirdetés
- Alaposan felpumpálta AI gyorsítójának izmait a Google
- Kisebb "atomreaktort" avatott a Minisforum
- A Microsoft bedurvult, így a jövőben keményen odacsapnak a veszélyes drivereknek
- Scalperektől félti RAM moduljait a Framework
- Drasztikusan lassíthatja a játékokat egyes VGA-kon a Windows 11 új frissítése
-
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
- Folyószámla, bankszámla, bankváltás, külföldi kártyahasználat
- Mennyibe fog kerülni a Steam Machine?
- Projektor topic
- Villanyszerelés
- Kicsomagoljuk és bemutatjuk a Poco F8 Ultrát
- Kerékpárosok, bringások ide!
- Fractal Scape – egy majdnem mindenes fejhallgató
- Samsung LCD és LED TV-k
- Bemutatkozott a Poco X7 és X7 Pro
- „Új mérce az Android világában” – Kezünkben a Vivo X300 és X300 Pro
- További aktív témák...
- Dell Precision 7510,15.6",FHD,i7-6820HQ,16GB DDR4,256GB SSD,M2000M 4GB VGA,WIN11
- LG UltraGear 32GQ85X-B felsőkategóriás LED Nano IPS Monitor eladó! 1440p 240Hz 1ms
- Getac ZX70 - Ütésálló tablet- Androidos - GPS /4G - Több darab érkezik - Új ára 580.000Ft
- ÚJ MSI CYBORG 15 A13VF - 15.6"FHD 144Hz - i5-13420H - 16GB - 512GB - Win11 - RTX 4060 -3 év garancia
- Gamer PC- I5 14400F,RX 5700 XT 8GB,16GB RAM,512GB NVMe
- ÁRGARANCIA!Épített KomPhone i5 10400F 16/32/64GB RAM RTX 3060 12GB GAMER PC termékbeszámítással
- ÁRGARANCIA!Épített KomPhone Ryzen 7 9800X3D 32/64GB RAM RTX 5070Ti 16GB GAMER PC termékbeszámítással
- Creality Nebula Camera
- Telefon felvásárlás!! iPhone 15/iPhone 15 Plus/iPhone 15 Pro/iPhone 15 Pro Max
- KIÁRUSÍTÁS - HP Elite / ZBook Thunderbolt 3 Dock (akár 2x4K felbontás)
Állásajánlatok
Cég: ATW Internet Kft.
Város: Budapest
Cég: Laptopműhely Bt.
Város: Budapest


