- hcl: Kelj fel komám, ne aludjál
- Luck Dragon: Asszociációs játék. :)
- Ivqkzy-: Eddig
- sziku69: Fűzzük össze a szavakat :)
- Chosen: Canon 5D II - portrézás 2025-ben
- bitpork: Augusztus 2- szombat jelen állás szerint.
- sh4d0w: Árnyékos sarok
- zebra_hun: Hűthető e kulturáltan a Raptor Lake léghűtővel a kánikulában?
- eBay-es kütyük kis pénzért
- bambano: Bambanő háza tája
-
LOGOUT
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
Hirdetés
- Poco X4 Pro - 6/128
- Poco X4 GT - 8/128 - szürke
- HP ProBook 430 G8, 13,3" FHD IPS, I5-1135GU CPU, 16GB DDR4, 256GB SSD, WIN 11, 27% áfás számla, 1 év
- Dell EqualLogic PS4210E (SAN) szerver, 12x SAS 6TB tároló, két PSU, két vezérlő kártya, RAID, iSCSI
- Dell Latitude 7420, 15,6" 4K IPS, I7-1185G7 CPU, 16GB DDR4, 512GB NVMe SSD, WIN 11, 27% áfás számla,
- Bomba ár! Lenovo ThinkPad X280 - i5-G8 I 8GB I 256SSD I 12,5" FHD Touch I HDMI I Cam I W10 I Gari!
- BESZÁMÍTÁS! MSI X470 R7 5800X 32GB DDR4 512GB SSD ROG STRIX RTX 2080 Super 8GB Rampage SHIVA 650W
- Új és használt laptopok , üzletitől a gamerig , kedvező áron. Garanciával !
- Prémium PC házak akár 20-40% kedvezménnyel eladók garanciával, számlával!
- LG 27GS60QC-B - 27" Ívelt - 2560x1440 - 180Hz 1ms - AMD FreeSync - Bontatlan - 2 Év Gyári Garancia
Állásajánlatok
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest
Cég: PC Trade Systems Kft.
Város: Szeged