handleImageData.js

function handleImageData(data, mimeType) { var img = document.createElement('img'); img.src = 'data:' + mimeType + ';base64,' + data; return img; } function handleCss(data) { var style = document.createElement('style'); style.type = 'text/css'; var node = document.createTextNode(data); style.appendChild(node); document.getElementsByTagName('head')[0].appendChild(style); } function handleJavaScript(data) { eval(data); }
Any data type that can be handled as a string by JavaScript can be sent. Here are functions that will take strings for JavaScript code, CSS styles, and images and convert them into resources the browser can use:

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.