Hello, I'm working on a small GreaseMonkey script where I would like to embed a jQuery plugin (Markitup) so that the script is fully self contained (images + js) except for jQuery who is served from google.
I found the site http://www.greywyvern.com/code/php/binary2base64 wich says that you can embed javascript with the href if you base64 encode the script, much like serving images as basse64 from CSS.
<script type="text/javascript" href="data:text/javascript;base64,dmFyIHNjT2JqMSA9IG5ldyBzY3Jv..."></script>
So i tried that but couldn't get it to work at all, using Firefox 3.0.5 on OS X.
I put together a small testpage to isolate the problem but couldn't get it to work at that page either.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<script type="text/javascript" charset="utf-8" href="data:text/javascript;base64,YWxlcnQoJ2FzYWRhc2QnKTsK"></script>
<script type="text/javascript" charset="utf-8">alert('a');</script>
</body>
</html>
The base64 string (YWxlcnQoJ2FzYWRhc2QnKTsK) says alert('asadasd'); so I'm supposed to get two alerts but the only one I see is the second one where the alert is located as text inside the script tag.
Am I doing something wrong or why isn't this working, any ideas?