JS实现登录后才发表评论,如果用户没登录就提示用户登录并有登录的链接,登录成功后才弹出评论输入框

JavaScript0132

JS实现登录后才发表评论,如果用户没登录就提示用户登录并有登录的链接,登录成功后才弹出评论输入框,第1张

建议使用jquery 很方便就能实现你要的效果,

在控件的onclick="loadDiv('login.aspx','','用户登录','modify')"

function loadDiv(url,option,title,divID)

{

var id=(new Date()).getTime()

if(divID)

{

colseDiv(divID)

id=divID

}

var div=$('<div id="msg'+id+'" class="message">')

if(url.indexOf('?')!=-1)

{

url+='&container='+id

}else

{

url+='?container='+id

}

var container=$('<div id="container'+id+'" class="container">')

var title=$('<div class="title">'+title+'<input type="image" name="imageField" id="imageField" src="/images/no.gif" alt="关闭" onclick="colseDiv(\''+id+'\')" style="position:absoluteright:0pxcursor:handborder:0px" onload="$(this).parent().find("#spanClose").css("display","none")"/><span id="spanClose" style="position:absoluteright:0pxcursor:handborder:0px" onclick="colseDiv(\''+id+'\')">关闭</span></div>')

container.append(title)

container.append(div)

div.html('<img src="/images/loading.gif"style="border:0px"><font color="red">正在加载,请稍候。。。</font>')

container.css("z-index",_conatinerID++)

$('body').append(container)

//var offset=$(event.srcElement).offset()

//var x = offset.left

//var y = offset.top

var x = 500

var y = 150

anchToTarget(id,x,y)

var data=null

if(option &&option.data)data=option.data

div.load(url,data,function()

{

anchToTarget(id,x,y)

if(option &&option.callback)

{

option.callback(id)

}

})

}

用到的核心样式.container{

position: absolute

z-index: 40

left:0px

top:0px

text-align:center

border-top:solid #4569A5 2px

border-left:solid #4569A5 2px

border-right:solid #6F91C8 2px

border-bottom:solid #6F91C8 2px

width:auto

}

用到的jquery.js代码太多,自己可以去百度上下载也可联系我给你

评论信息或评论表单在同一个页面中,但是alert发表成功后源码天空

,返回上一页时却无法自动刷新,只有按了刷新菜单后才能显示出来新发表的评论。

提交评论的代码如下:[code]response.write "<script language='javascript'" &chr(13)

response.write "alert('评论提交成功!')" &Chr(13)

response.write "window.document.location.href='javascript:onclick=history.go(-1)'"&Chr(13)

response.write "</script" &Chr(13)

Response.End[/code]解决方法:response.write "<script language='javascript'" &chr(13)

response.write "alert('评论提交成功!')" &Chr(13)

response.write "window.document.location.href='这里改成上一页的URL地址'"&Chr(13)

response.write "</script" &Chr(13)

Response.End

response.write "<script language='javascript'" &chr(13)

response.write "alert('评论提交成功!')" &Chr(13)

response.write "window.document.location.href='"&Request.ServerVariables("HTTP_REFERER")&"'"&Chr(13)

response.write "</script" &Chr(13)

Response.Endok !后退刷新代码:

[code]<%Response.Expires = -1

Response.cachecontrol = "no-cache"%[/code]放到asp页的开头,再点后退,就会强制刷新..