[置顶] 帝国CMS缺省例子首页面的tab框不能在Firefox上正常运行的修正

21 篇文章 0 订阅
14 篇文章 0 订阅

skin/default/js/tabs.js 源文件中仅仅考虑了IE的情况,

写道
//在IE上空白节点不算DOM节点,在火狐上算

 

这一点没有注意,导致在火狐上出现代码错误... 修正的代码如下:

 

/*色色修改版: vb2005xu.iteye.com , 解决此文件在火狐浏览器空节点取属性值的错误*/


function $xudtitle(str){
	document.title = str;
}
//在IE上空白节点不算,在火狐上算.等于在IE上数量为4,在火狐上就为9
function $xu(id){
	return document.getElementById(id);
}
//是否元素节点
function $xuisele(id){
	var node = $xu(id);
	if(node && node.nodeType ==1)
		return true;
	return false ;
}
//取元素中第一个子元素节点
function $xufelenode(id){
	var node = $xu(id);
	while(node && node.nodeType !=1)
		node = node.nextSibling();
	return node ;
}
function $xushow(id){
	$xu(id).style.display = "" ;
}
function $xublock(id){
	$xu(id).style.display = "block" ;
}
function $xuhide(id){
	$xu(id).style.display = "none" ;
}

function tabit(btn){
	var idname = new String(btn.id);
	var s = idname.indexOf("_");
	var e = idname.lastIndexOf("_")+1;
	var tabName = idname.substr(0, s);
	var id = parseInt(idname.substr(e, 1));
	var tabNumber = btn.parentNode.childNodes.length;
	for(i=0;i<tabNumber;i++){
		
		if ($xuisele(tabName+"_btn_"+i)) {
			$xu(tabName+"_btn_"+i).className = "";
		}
	};
	btn.className = "curr";
};

function etabit(btn){
	var idname = new String(btn.id);
	var s = idname.indexOf("_");
	var e = idname.lastIndexOf("_")+1;
	var tabName = idname.substr(0, s);
	var id = parseInt(idname.substr(e, 1));
	
	var tabNumber = btn.parentNode.childNodes.length;
	for(i=0;i<tabNumber;i++){
		if ($xuisele(tabName+"_div_"+i)) {
			$xuhide(tabName+"_div_"+i);
			$xu(tabName+"_btn_"+i).className = "";
		}
	};
	document.getElementById(tabName+"_div_"+id).style.display = "block";
	btn.className = "curr";
};

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可以通过 ActivityManager 的 getRunningTasks() 方法获取任务栈信息,判断栈顶的任务是否属于目标应用,来判断目标应用是否正在运行。如果目标应用正在运行,则通过 Intent.FLAG_ACTIVITY_REORDER_TO_FRONT 标志将其置顶;如果目标应用未运行,则通过 Intent.FLAG_ACTIVITY_NEW_TASK 标志打开它。下是一个示例代码: ``` public void openOrTopApp(Context context, String packageName) { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningTaskInfo> runningTasks = activityManager.getRunningTasks(1); if (runningTasks != null && !runningTasks.isEmpty()) { ActivityManager.RunningTaskInfo taskInfo = runningTasks.get(0); ComponentName componentName = taskInfo.topActivity; if (componentName.getPackageName().equals(packageName)) { // 目标应用正在运行,将其置顶 Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setComponent(componentName); intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); context.startActivity(intent); } else { // 目标应用未运行,打开它 Intent intent = context.getPackageManager().getLaunchIntentForPackage(packageName); if (intent != null) { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } } } } ``` 其中,Context 是应用的上下文,packageName 是目标应用的包名。函数通过 ActivityManager.getRunningTasks() 获取当前栈顶的任务信息,然后判断其包名是否与目标应用一致。如果一致,说明目标应用正在运行,将其置顶;如果不一致,说明目标应用未运行,打开它。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值