Regarding Place JavaScript code at bottom of page in asp.net
i have one master page for my website. i place simple script tag before closing body tag. like
<body>
here will be content placeholder
<script src="js/jquery开发者_JAVA技巧-1.2.6.min.js" type="text/javascript"></script>
</body>
in my content page i have script tag like
<script type="text/javascript">
$("a.foo").click(doSomething);
function doSomething()
{
return confirm("About to visit " + this.href + ", continue?");
}
</script>
but i want this script tag should be place at runtime just before the closing of body tag. how could i do this....do i need to write any code ? please help me with best suggestion.
thanks
Don't bother with this. Put the jQuery library on the head section of the master page. Use a CDN so that it is cached, then put your script anywhere you want inside your content place holder.
If you can't use a CDN, then configure your web server to cache Javascript files. It's very simple. See here.
精彩评论