Slide show

Text area how to Save and Load files


HTML: *Importand Visual Editor do NOT Update HTML automaticaly !!!
Filename to Save As:
Select a File to Load:

Preview:

</script>


<script type="text/javascript">
 
function saveTextAsFile()
{
    var textToSave = document.getElementById("text2").value;
    var textToSaveAsBlob = new Blob([textToSave], {type:"text/plain"});
    var textToSaveAsURL = window.URL.createObjectURL(textToSaveAsBlob);
    var fileNameToSaveAs = document.getElementById("inputFileNameToSaveAs").value;
 
    var downloadLink = document.createElement("a");
    downloadLink.download = fileNameToSaveAs;
    downloadLink.innerHTML = "Download File";
    downloadLink.href = textToSaveAsURL;
    downloadLink.onclick = destroyClickedElement;
    downloadLink.style.display = "none";
    document.body.appendChild(downloadLink);
 
    downloadLink.click();
}
 
function destroyClickedElement(event)
{
    document.body.removeChild(event.target);
}
 
function loadFileAsText()
{
    var fileToLoad = document.getElementById("fileToLoad").files[0];
 
    var fileReader = new FileReader();
    fileReader.onload = function(fileLoadedEvent) 
    {
        var textFromFileLoaded = fileLoadedEvent.target.result;
        document.getElementById("text2").value = textFromFileLoaded;
      tinymce.get("text1").setContent(textFromFileLoaded);  
     
    };
    fileReader.readAsText(fileToLoad, "UTF-8");
}
 
</script>


<!-- <button onclick="displayOut()"> Update Html </button> -->


  Filename to Save As: <input id="inputFileNameToSaveAs"></input> 
<button onclick="saveTextAsFile()"> Save HTML to File </button>
<button onclick="myFunction()">  Copy HTML to Clipboard </button>
<br>
Select a File to Load: <input type="file" id="fileToLoad">
<button onclick="loadFileAsText()"> Load Selected File </button>

NEW !!! You can actively participate in the wordpress911 team to ask and answer questions to upload articles and videos register » Here

Links: You can download the best WordPress Woocommerce templates HERE


No comments:

Post a Comment