How to attach base64 encoded script to a div

Hi guys,

How to attach this base64 encoded script to a div and execute.

var a = 'Y29uc29sZS5sb2coJ2FiY2RlZmdoaWxtbmprJyk=';

var c = document,
    d = c.getElementById('myDiv'),
    e = c.createElement('script');

e.src = 'data:text/javascript;base64,' + a;
d.appendChild(e);

I’ve tried and it failed.
Thank you,

What browser were you using? I seems to work in Chrome.

Hi,
Thank you. I use Chrome and get this error:

GET data:text/javascript;base64,console.log('abcdefghilmnjk') net::ERR_INVALID_URL

Hm, on Chrome for Mac it works. Are you placing the script just before the closing body tag?

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
<div id="myDiv"></div>
<script>
	var a = 'Y29uc29sZS5sb2coJ2FiY2RlZmdoaWxtbmprJyk=';
	var c = document,
	d = c.getElementById('myDiv'),
	e = c.createElement('script');
	e.src = 'data:text/javascript;base64,' + a;
	d.appendChild(e);
</script>
</body>
</html>

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.