Use included javascript from external page
What I am trying to do, is display an external page, change the css, and display it to the user, with Jquery/javascript+phonegap. However, if the external page has script
tags, which include .js
files, then they are excluded, because, I need to modify and save the html locally, then display it again.
Is there a way or is it even possible to include the referenced .js
files in the saved external html? I know there are reasons for not allowing to save those files locally, but I only need to use them, not read the contents. I know I can modify the head
element to include 'public' .js files,开发者_JAVA百科 such as jquery, but how about 'private' .js files?
The jQuery get() method is useful here. With no argument, it returns all matches in an array. Testing on the W3Schools site seems to reveal this behavior, and, jQuery being a library, I would expect this is not browser dependent.
http://www.w3schools.com/jquery/misc_get.asp
You could use
$("script").get()
to find all script tags. You could even use
$("script").get().filter(function(x){return x.src})
.map(function(x){return x.src}
Even better is
$("script[src]").get().map(function(x){return x.href})
jQuery is a good example of language extension.
精彩评论