//Code by ThichCode.NET
function copyToClipboard(text) {
if (window.clipboardData && window.clipboardData.setData) {
// IE specific code path to prevent textarea being shown while dialog is visible.
return clipboardData.setData("Text", text);
} else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
var textarea = document.getElementById('stringHTML');
textarea.textContent = text;
//textarea.style.position = "fixed"; // Prevent scrolling to bottom of page in MS Edge.
//document.body.appendChild(textarea);
textarea.select();
try {
return document.execCommand("copy"); // Security exception may be thrown by some browsers.
} catch (ex) {
console.warn("Copy to clipboard failed.", ex);
return false;
} finally {
//document.body.removeChild(textarea);
}
}
}
$('button#stripHTML').click(function(){
var stringHTML = $('textarea#stringHTML').val(); //alert(stringHTML);
//var e = $(stringHTML);
$('#result').empty().append($.parseHTML(stringHTML)); //alert(e.outerHTML);
$('#result').find('[style]').removeAttr('style');
$('#result').find('[class]').removeAttr('class');
$('#result').find('[id]').removeAttr('id');
$('textarea#stringHTML').val($('#result').html());
});
// Get the modal
var modal = document.getElementById('myModal');
// Get the button that opens the modal
var btn = document.getElementById("openResult");
// Get the element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks on the button, open the modal
btn.onclick = function() {
modal.style.display = "block";
}
// When the user clicks on (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
Post a Comment