0

I have the following .js file, call it myScript.js, which contains the code:

function Something()
{

}

It is embedded in the main HTML as such:

<script src="myScript.js"></script>

I want to obtain the output

function Something()
{

}

Normally, one would use the DOM to extract the script via .innerHTML, but in this case .innerHTML returns an empty string. How would the result be achieved in this case?

2
  • Now why do you need this? Commented May 31, 2013 at 7:26
  • Yup, it indeed is a duplicate. Please close this question. Thank you. Commented May 31, 2013 at 7:31

1 Answer 1

0

You should be able to load the script trough ajax, but this will only work if it's on the same domain.

If it's not on the same domain you can implement a server side function that grabs a provided page and then returns it

Sign up to request clarification or add additional context in comments.

3 Comments

Please provide feedback if you downvote, the PO wants to get the actual contents of the script, not load the script.
The downvote was because your answer was more of a comment/one liner before you edited the answer.Removed the downvote :-)
well it's a two liner now, i can't really help it if the answer is very short :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.