I'm trying to write my own scripting-language parser in JavaScript using html <script>
tag with custom type
attribute. For inline scripts it's easy:
<script>
//JS parser
function λParse(code){/*...*/}
var arr = document.querySelectorAll(
'script[type="application/x-lambdascript"]'
);
l=arr.length;
while(l--){
λParse(arr[l].textContent);
}
</script>
But it's a bit harder for external scripts. I'm able to get the src
attribute but that's all.
Is there any universal solution of getting the contents of an external file? I know it's probably possible using XMLHttpRequest
but what about webpages saved on my own computer? Is there any API for it?
Thanks.