以编程方式在页眉中添加javascrip引用(或完整脚本)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了以编程方式在页眉中添加javascrip引用(或完整脚本)相关的知识,希望对你有一定的参考价值。
Place javascrip refernce or complete javascript code in page header from ascx or aspx file.
// add reference like this script1.Attributes.Add("type", "text/javascript"); script1.Attributes.Add("src", "../js/prototype.js"); this.Page.Header.Controls.Add(script1); // add full script like this // first create string which contains your javascript string YahooScript = ""; YahooScript = " " + "YAHOO.util.Event.onContentReady("izbornik", function () { " + "var oMenuBar = new YAHOO.widget.MenuBar("izbornik", {autosubmenudisplay: true, hidedelay: 750, lazyload: true }); " + "oMenuBar.render(); " + "}); "; // and then place javascript in header script3.Attributes.Add("type", "text/javascript"); script3.InnerHtml = YahooScript; this.Page.Header.Controls.Add(script3); // in aspx page you can add script using Literal control // place Literal control in page Header in code view. // create your script string string temaSkripta = ""; temaSkripta = " " + "function kojaTema() " + "{" + "var tema = '" + tema + "'; " + "return tema;" + "}"; // find Literal in heder and make your string it's text. Literal L = (Literal)Header.FindControl("Literal1"); L.Text = temaSkripta;
以上是关于以编程方式在页眉中添加javascrip引用(或完整脚本)的主要内容,如果未能解决你的问题,请参考以下文章
以编程方式添加没有 VBE 或 VBIDE 的 VBA 项目引用..?