开发者

Loop through all the <script /> tags on a page

开发者 https://www.devze.com 2023-04-13 01:50 出处:网络
I want to loop through all the referenced Javascript files on an ASP.Net page. In other words, I want to enumerate all the

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号