
function fetchJSONFile(path, callback) { var httpRequest = new XMLHttpRequest(); httpRequest.onreadystatechange = function() { if (httpRequest.readyState === 4) { if (httpRequest.status === 200) { var data = JSON.parse(httpRequest.responseText); if (callback) callback(data); } } }; httpRequest.open('GET', path); httpRequest.send(); } fetchJSONFile('file.json', function(data){ // Do something with Data console.log(data); });
/* trim-whitespace-input.js*/ $('.no-spaces-field').keyup(function() { $(this).val($(this).val().replace(/ +?/g, '')); });
/* Download Textarea Content as Html File.js */ $('#download-button').click(function() { if ('Blob' in window) { var fileName = prompt('Please enter file name to save', 'Untitled.html'); if (fileName) { var textValue = $('textarea').html(); var textToWrite = htmlDecode(textValue); var textFileAsBlob = new Blob([textToWrite], { type: 'application/xhtml+xml' }); if ('msSaveOrOpenBlob' in navigator) { navigator.msSaveOrOpenBlob(textFileAsBlob, fileName); } else { var downloadLink = document.createElement('a'); downloadLink.download = fileName; downloadLink.innerHTML = 'Download File'; if ('webkitURL' in window) { downloadLink.href = window.webkitURL.createObjectURL(textFileAsBlob); } else { downloadLink.href = window.URL.createObjectURL(textFileAsBlob); downloadLink.click(function() { document.body.removeChild(event.target); }); downloadLink.style.display = 'none'; document.body.appendChild(downloadLink); } downloadLink.click(); } } } else { alert('Your browser does not support the HTML5 Blob.'); } });
/* Create iFrame from Textarea Content Html */ function setFrame() { var HTMLval = TextareaContentID.value; var iframe = document.getElementById('iframeID'); iframe.contentWindow.document.open(); iframe.contentWindow.document.write(HTMLval); iframe.contentWindow.document.close(); }
// Hide Div when Click Outside of the Element using jQuery / https://www.codexworld.com/ $(document).mouseup(function(e){ var container = $("#elementID"); // If the target of the click isn't the container if(!container.is(e.target) && container.has(e.target).length === 0){ container.hide(); } });
/* Detect iOs */ if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) { // do something }
Loading...
No more items to load