永发信息网

JS的调用

答案:2  悬赏:50  手机版
解决时间 2021-02-01 05:31
  • 提问者网友:精神病院里
  • 2021-01-31 04:42
asp.net前台JS代码
<script type="text/javascript">
var outlookbar=new outlook();
var t;
t=outlookbar.addtitle('基本设置','系统设置',1);
outlookbar.additem('查看个人资料',t,'profile.html');
function outlook()
{
this.titlelist = new Array();
this.itemlist = new Array();
this.addtitle = addtitle;
this.additem = additem;
this.getbytitle = getbytitle;
this.getbyitem = getbyitem;
this.getdefaultnav = getdefaultnav;
}
function addtitle(intitle, sortname, inisdefault)
{
outlookbar.itemlist[outlookbar.titlelist.length] = new Array();
outlookbar.titlelist[outlookbar.titlelist.length] = new theitem(intitle, sortname, 0, inisdefault);
return (outlookbar.titlelist.length - 1);
}
function additem(intitle, parentid, inkey)
{
if(parentid >= 0 && parentid <= outlookbar.titlelist.length)
{
insort = "item_" + parentid;
outlookbar.itemlist[parentid][outlookbar.itemlist[parentid].length] = new theitem(intitle, insort, inkey, 0);
return (outlookbar.itemlist[parentid].length - 1);
}
else additem = - 1;
}
</script>
提问以下的这两句放到后台去怎么弄?那位高手帮帮忙。
t=outlookbar.addtitle('基本设置','系统设置',1);
outlookbar.additem('查看个人资料',t,'profile.html');
最佳答案
  • 五星知识达人网友:空山清雨
  • 2021-01-31 05:59
//后台定义一个方法,因需前台访问所以定义成public
//方法返回一个字符串
//原理就是把JS代码和数剧在后带组合成字符串返回到前台中
public string getdata()
{
string strtmp="";
//请自行提取所需数据
strtmp+=" t=outlookbar.addtitle('基本设置','系统设置',1);";
strtmp+="outlookbar.additem('查看个人资料',t,'profile.html');";
strtmp+="outlookbar.additem('查看个人资料',t,'profile.html');";
strtmp+="outlookbar.additem('查看个人资料',t,'profile.html');“;
strtmp+="t=outlookbar.addtitle('基本设置','系统设置',1);";
strtmp+="outlookbar.additem('查看个人资料',t,'profile.html');";
return strtmp;//返回数据字符串
}

<script type="text/javascript">
var outlookbar=new outlook();
var t;
//前台处直接调用后台方法
<%=getdata() %>
function outlook()
{

以上为.netC#语话换别的也是可行的``楼主请自行测试
全部回答
  • 1楼网友:孤独的牧羊人
  • 2021-01-31 06:27
js属于客户端的代码,你可以这样调用:在前台中引用后台变量,如: t=outlookbar.addtitle(<%=jbsz%>,(<%=xtsz%>,1);//其中jbsz,xtsz是你在后台定义的变量 outlookbar.additem('查看个人资料',t,<%=varpage%>);
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯