Loop through all the <script /> tags on a page
I want to loop through all the referenced Javascript files on an ASP.Net page.
In other words, I want to enumerate all the
<script src="a.js" type="text/javascript"></script>
<script src="b.js" type="text/javascript"></script>
<script src="c.js" type="text/javascript"></script>
tags on a page.
Of course, I can't do this because they are not act开发者_如何学JAVAually visible to ASP.Net. They do not have a runat="server" tag on them. And, of course, if you add a runat="server" tag to them, then ASP.Net is going to actually try to run the javascript on the server (perhaps the only time where runat="server" has a real use!)
Am I out of luck here? I think I am, but it is worth asking.
Are they all in the <head>
of the page? If so make the head runat=server
, then I'm pretty sure they become part of the Page.Header.Controls
collection
精彩评论