<script id="s1" src="foo.js"></script>
<script>
alert('foo.js contains' + _source_code_of('s1'))
</script>
Can _source_code_of be implemented?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, this would allow to retrieve the contents of any URL, which would break some security policies. (This would be an equivalent of an ajax get request without same-domain checks.)
However, since
foo.jsis on the same domain than the page you can fetch it with an ajax request. Example with jQuery: