织梦实现在网站顶部显示会员登录信息(3)

注意:得重新包含dedeajax2.js和j.js文件,因为虽然我们之前在index.htm中定义过了,但是是引用不到的。

<script language="javascript" type="text/javascript" src=http://www.dede58.com/"{dede:global.cfg_cmsurl/}/include/dedeajax2.js"></script> <script language="javascript" type="text/javascript" src=http://www.dede58.com/"{dede:global.cfg_templets_skin/}/js/j.js" ></script> <SCRIPT language=javascript type=text/javascript> <!-- function CheckLogin_head(){ var taget_obj_head = document.getElementById('_userlogin_head'); myajax_head = new DedeAjax(taget_obj_head,false,false,'','',''); myajax_head.SendGet2("{dede:global.cfg_cmspath/}/member/ajax_loginsta_head.php"); DedeXHTTP = null; } --> </SCRIPT>  

4、其实第3步大家有注意到了我们是根据ajax_loginsta_head.php文件来获得结果HTML代码的。

ajax_loginsta_head.php文件是由ajax_loginsta.php 复制粘贴出来的,我们在它的基础上改为:

require_once(dirname(__FILE__)."/config.php"); AjaxHead(); if($myurl == '') exit(''); $uid = $cfg_ml->M_LoginID; !$cfg_ml->fields['face'] && $face = ($cfg_ml->fields['sex'] == '女')? 'dfgirl' : 'dfboy'; $facepic = empty($face)? $cfg_ml->fields['face'] : $GLOBALS['cfg_memberurl'].'/templets/images/'.$face.'.png'; ?> <div> <script type="text/javascript"> var now=(new Date()).getHours(); if(now>0&&now<=6){ document.write("午夜好,"); }else if(now>6&&now<=11){ document.write("早上好,"); }else if(now>11&&now<=14){ document.write("中午好,"); }else if(now>14&&now<=18){ document.write("下午好,"); }else{ document.write("晚上好,"); } </script> 你好:<strong><?php echo $cfg_ml->M_UserName; ?></strong>,欢迎登录 <a href=http://www.dede58.com/"<?php echo $cfg_memberurl; ?>/index_do.php?fmdo=login&dopost=exit">退出登录</a> </div><!-- /userinfo -->  

OK,效果显示出来了。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/36be20cebfd639eb3e08c81150fcc885.html