永发信息网

JS的调用

答案:2  悬赏:50  手机版
解决时间 2021-02-01 05:31
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');
最佳答案
//后台定义一个方法,因需前台访问所以定义成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#语话换别的也是可行的``楼主请自行测试
全部回答
js属于客户端的代码,你可以这样调用:在前台中引用后台变量,如: t=outlookbar.addtitle(<%=jbsz%>,(<%=xtsz%>,1);//其中jbsz,xtsz是你在后台定义的变量 outlookbar.additem('查看个人资料',t,<%=varpage%>);
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
SGS 通标公司 检验工程师面试
(假设信息)如果出现急性乳头肌功能不全,心
1964.12.1.幸运数字和颜色
我的是苹果7p用了13天可以退货吗
美国电影中经常出现的“you bastered”是什么
赵思薄这个名字的意思好吗
右手无名指有痣
根据下面词语的不同意思造句。
一个函数的图像是经过原点的直线,并且这条直
求 牡丹江去青岛的长途客车票价和时间 以及上
一个月6000的工资抚养费要多少
有关于黄河的成语故事吗要有它的意义和相关故
为什么过氧化物加入聚丙烯中熔融指数会高
猜成语 1.拿筷子吃饭 2.手机不能掉水里 3.
属狗买房风水
推荐资讯
成都市新都区石板滩东风村6社队长贪污
2O16年淮安市提取住房公积金要有那些手续?
如果电脑系统装在固态硬盘里,但显示出来固态
小女儿满周岁,又乔迁之喜,2喜同贺求大门对
男友不愿买房,只住50平米老房
求后宫管家学院无修网盘有发立马采纳
【陕西师范大学附属中学】英语翻译陕西师范大
年交五万的保险,缴费十年,该交第二年,想退保,
∠BGE B、∠AHE=∠BGE C、∠AHE
安在门上的整人方法
标志为什么挂倒挡车不走
凤凰酒店停车场(出入口)(凤凰酒店停车场)地址
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?