1. 程式人生 > >控制頁內頁外跳轉

控制頁內頁外跳轉

<div class="admin">
	         <a href="javascript:void(0)" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-bkgl'" 
	         	data-icon="icon-ok" data-link="test/admin-index" style="width: 150px;" iframe="0">管理員登入</a>
</div>

$(function() {
			$('.admin a').bind("click", function() {
				/* alert("hello"); */
				var title = $(this).text();
				var url = $(this).attr('data-link');
				var iconCls = $(this).attr('data-icon');
				var iframe = $(this).attr('iframe') == 1 ? true : false;
				/* alert(iframe); */
				alert(url);
				admin_index(title, url, iconCls, iframe);
			});
		});
		function admin_index(title, href, iconCls, iframe){
			var tabPanel = $('#tabs');
			if(!tabPanel.tabs('exists',title)){
				var content = '<iframe scrolling="auto" frameborder="0"  src="'+ href +'" style="width:100%;height:100%;"></iframe>';
				if(iframe){ /* inframe為true  頁面內跳轉 */
					/* alert("iframe=true"); */
					tabPanel.tabs('add',{
						title:title,
						content:content,
						iconCls:iconCls,
						fit:true,
						cls:'pd3',
						closable:true
					});
				}
				else{/* inframe為false執行  頁面外部跳轉*/
					alert("iframe=false");
					$(location).attr('href',href);
					/*tabPanel.tabs('add',{
						title:title,
						href:href,
						iconCls:iconCls,
						fit:true,
						cls:'pd3',
						closable:true
					}); */
				}
			}
			else
			{	
				alert("iframe=3");
				tabPanel.tabs('select',title);
			}
		}

通過iframe控制頁面內部還是外部跳轉在標籤內部設定iframe