MVC+EasyUI+三層新聞網(wǎng)站建立 tabs標(biāo)簽制作方法(六)
MVC新聞網(wǎng)站建立,完成tabs標(biāo)簽的制作。
首先對(duì) Center 進(jìn)行一個(gè)簡(jiǎn)單的布局
<!--------------中間布局開(kāi)始---------------->
<div data-options="region:'center',title:'Center'" >
<div class="easyui-tabs" style="width:700px;height:250px" fit="true" id="tt">
<div title="歡迎使用">
<h1 style="font-size: 24px;">歡迎!</h1>
<h1 style="font-size: 24px; color:red;"> Welcome !</h1>
</div>
</div>
</div>
<!--------------中間布局結(jié)束--------------->
然后就是在js里面完成tabs的點(diǎn)擊事件實(shí)現(xiàn)了
其實(shí)center就是在div里面嵌入了一個(gè)iframe,所以最后返回的就是一個(gè)iframe
<script type="text/javascript">
$(function () {
//tabs的點(diǎn)擊事件
bindTabsEvent();
});
function bindTabsEvent() {
$(".detail").click(function () {
//拿到點(diǎn)擊標(biāo)題
var title = $(this).text();
//拿到點(diǎn)擊的url
var url = $(this).attr("url");
//判斷標(biāo)簽是否存在
var isExt = $("#tt").tabs("exists", title);
//如果存在則選中
if (isExt) {
$("#tt").tabs("select", title); //選中
return;
}
//不存在就添加標(biāo)簽
$("#tt").tabs("add", {
title: title,
content: createTabContent(url),
closable:true
});
});
}
function createTabContent(url) {
return '<iframe src="' + url + '" scrolling="no" frameborder="0" width="100%" height="100%"></iframe>';
}
</script>
這里需要注意一點(diǎn)就是上面的detail是導(dǎo)航欄的類(lèi)選擇器的值(這里的class一定要一樣)

整個(gè)頁(yè)面代碼
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
<script src="~/Scripts/jquery-1.8.2.js"></script>
<script src="~/Content/EasyUI/jquery.easyui.min.js"></script>
<script src="~/Content/EasyUI/easyui-lang-zh_CN.js"></script>
<link href="~/Content/EasyUI/themes/default/easyui.css" rel="external nofollow" rel="stylesheet" />
<link href="~/Content/EasyUI/themes/icon.css" rel="external nofollow" rel="stylesheet" />
<script type="text/javascript">
$(function () {
//tabs的點(diǎn)擊事件
bindTabsEvent();
});
function bindTabsEvent() {
$(".detail").click(function () {
//拿到點(diǎn)擊標(biāo)題
var title = $(this).text();
//拿到點(diǎn)擊的url
var url = $(this).attr("url");
//判斷標(biāo)簽是否存在
var isExt = $("#tt").tabs("exists", title);
//如果存在則選中
if (isExt) {
$("#tt").tabs("select", title); //選中
return;
}
//不存在就添加標(biāo)簽
$("#tt").tabs("add", {
title: title,
content: createTabContent(url),
closable:true
});
});
}
function createTabContent(url) {
return '<iframe src="' + url + '" scrolling="no" frameborder="0" width="100%" height="100%"></iframe>';
}
</script>
</head>
<body class="easyui-layout">
<div data-options="region:'north',border:false" style="height:60px;background:#B3DFDA;padding:10px">north region</div>
<!---------左側(cè)布局------------------------------------>
<div data-options="region:'west',split:true,title:'West'" style="width:150px;padding:0px;">
<div class="easyui-accordion" style="width:auto;height:auto;">
<div title="新聞管理" data-options="iconCls:'icon-ok'" style="overflow:auto;padding:10px;">
<a href="javascript:void(0)" rel="external nofollow" rel="external nofollow" class="detail" url="/AdminNewInfo/Index">新聞管理</a>
</div>
<div title="評(píng)論管理" data-options="iconCls:'icon-ok'" style="overflow:auto;padding:10px;">
<a href="javascript:void(0)" rel="external nofollow" rel="external nofollow" class="detail" url="/CommentInfo/Index">評(píng)論管理</a>
</div>
</div>
</div>
<!---------左側(cè)布局結(jié)束------------------------------------>
<div data-options="region:'south',border:false" style="height:30px;background:#A9FACD;padding:10px;">south region</div>
<!--------------中間布局開(kāi)始---------------->
<div data-options="region:'center',title:'Center'" >
<div class="easyui-tabs" style="width:700px;height:250px" fit="true" id="tt">
<div title="歡迎使用">
<h1 style="font-size: 24px;">歡迎!</h1>
<h1 style="font-size: 24px; color:red;"> Welcome !</h1>
</div>
</div>
</div>
<!--------------中間布局結(jié)束--------------->
</body>
</html>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
微信公眾平臺(tái)開(kāi)發(fā)之語(yǔ)音識(shí)別.Net代碼解析
這篇文章主要為大家詳細(xì)解析了微信公眾平臺(tái)開(kāi)發(fā)之語(yǔ)音識(shí)別.Net代碼,感興趣的小伙伴們可以參考一下2016-06-06
解析ABP框架中的數(shù)據(jù)傳輸對(duì)象與應(yīng)用服務(wù)
ABP框架是基于ASP.NET的Web開(kāi)發(fā)框架,在ABP中應(yīng)用服務(wù)將領(lǐng)域邏輯暴露給展現(xiàn)層,展現(xiàn)層通過(guò)傳入數(shù)據(jù)傳輸對(duì)象參數(shù)來(lái)調(diào)用應(yīng)用服務(wù),而這里我們就來(lái)解析ABP框架中的數(shù)據(jù)傳輸對(duì)象與應(yīng)用服務(wù)2016-06-06
ASP.NET中后臺(tái)注冊(cè)js腳本使用的方法對(duì)比
接下來(lái)為大家介紹下使用Page.ClientScript.RegisterClientScriptBlock 和Page.ClientScript.RegisterStartupScript:區(qū)別2013-04-04
ASP.NET Core Web資源打包與壓縮技術(shù)介紹
這篇文章介紹了ASP.NET Core Web資源打包與壓縮技術(shù),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-02-02
簡(jiǎn)單Web service 身份驗(yàn)證解決方案
問(wèn)題提出:為了構(gòu)建一個(gè)安全的web服務(wù),需要對(duì)調(diào)用方進(jìn)行身份驗(yàn)證,只讓通過(guò)審核的用戶(hù)調(diào)用web服務(wù)。2009-05-05
asp.net基于替換模版頁(yè)的形式生成靜態(tài)頁(yè)的方法
這篇文章主要介紹了asp.net基于替換模版頁(yè)的形式生成靜態(tài)頁(yè)的方法,涉及asp.net模板的設(shè)置、變量替換、配置文件設(shè)置與讀取、以及文件夾與靜態(tài)文件的創(chuàng)建等技巧,需要的朋友可以參考下2016-07-07
.NET5控制臺(tái)程序使用EF連接MYSQL數(shù)據(jù)庫(kù)的方法
這篇文章主要介紹了.NET5控制臺(tái)程序使用EF連接MYSQL數(shù)據(jù)庫(kù),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-08-08

