Calling javascript function in iframe

Use: document.getElementById(“resultFrame”).contentWindow.Reset(); to access the Reset function in the iframe document.getElementById(“resultFrame”) will get the iframe in your code, and contentWindow will get the window object in the iframe. Once you have the child window, you can refer to javascript in that context. Also see HERE in particular the answer from bobince.

How to convert Base64 String to javascript file object like as from file input form?

Way 1: only works for dataURL, not for other types of url. function dataURLtoFile(dataurl, filename) { var arr = dataurl.split(‘,’), mime = arr[0].match(/:(.*?);/)[1], bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n); while(n–){ u8arr[n] = bstr.charCodeAt(n); } return new File([u8arr], filename, {type:mime}); } //Usage example: var file = dataURLtoFile(‘data:text/plain;base64,aGVsbG8gd29ybGQ=’,’hello.txt’); console.log(file); Way 2: works for … Read more

JavaScript XMLHttpRequest using JsonP

JSONP does not use XMLHttpRequests. The reason JSONP is used is to overcome cross-origin restrictions of XHRs. Instead, the data is retrieved via a script. function jsonp(url, callback) { var callbackName=”jsonp_callback_” + Math.round(100000 * Math.random()); window[callbackName] = function(data) { delete window[callbackName]; document.body.removeChild(script); callback(data); }; var script = document.createElement(‘script’); script.src = url + (url.indexOf(‘?’) >= 0 … Read more

Stop User from using “Print Scrn” / “Printscreen” key of the Keyboard for any Web Page

I hate the “it’s not possible” sentence. Here’s all solutions combined to help you: 1- You can grab the solution from Haluk: <script type=”text/javascript”> $(document).ready(function() { $(window).keyup(function(e){ if(e.keyCode == 44){ $(“body”).hide(); } }); }); </script> HOWEVER, you hide body, but’s already “printed” to clipboard. You can fire another event that copy some text to your … Read more

event.preventDefault() vs. return false (no jQuery)

The W3C Document Object Model Events Specification in 1.3.1. Event registration interfaces states that handleEvent in the EventListener has no return value: handleEvent This method is called whenever an event occurs of the type for which the EventListener interface was registered. […] No Return Value under 1.2.4. Event Cancelation the document also states that Cancelation … Read more