后台:
protected void BTN_PL_Click(object sender, EventArgs e)
{
Page.RegisterStartupScript("aaa", " <script>showTips(); </script>");
}JS函数:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
function showTips() {
var time = 1;
var tips = '保存成功';
var btn_bc=document.getElementById('BTN_BC');
var windowWidth = btn_bc.offsetLeft + btn_bc.offsetWidth + 10;
var height = btn_bc.offsetTop + 4;
var tipsDiv = '<div id="stps" class="tipsClass"><div style=" float:left;"><img src="img/ts.png"/></div><div style=" float:left;margin-top:1px; margin-bottom:1px;">' + tips + '</div></div>';
$('body').append(tipsDiv);
$('div.tipsClass').css({
'top': height + 'px',
'left': windowWidth + 'px',
'position': 'absolute',
'font-size': 12 + 'px',
'color': '#0094ff',
'text-align': 'center',
'width': 'auto',
'line-height': 16 + 'px',
'opacity': '0.8'
}).show();
setTimeout(function () { $('div.tipsClass').fadeOut(); }, (time * 1000));
}后台调用JS函数没有问题,现在的问题是多次调用后,点击浏览器上的退回上一步会再次进入showTips()函数。按理应该是只有用户点击按钮才执行。现在的情况求解????????
protected void BTN_PL_Click(object sender, EventArgs e)
{
Page.RegisterStartupScript("aaa", " <script>showTips(); </script>");
}JS函数:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
function showTips() {
var time = 1;
var tips = '保存成功';
var btn_bc=document.getElementById('BTN_BC');
var windowWidth = btn_bc.offsetLeft + btn_bc.offsetWidth + 10;
var height = btn_bc.offsetTop + 4;
var tipsDiv = '<div id="stps" class="tipsClass"><div style=" float:left;"><img src="img/ts.png"/></div><div style=" float:left;margin-top:1px; margin-bottom:1px;">' + tips + '</div></div>';
$('body').append(tipsDiv);
$('div.tipsClass').css({
'top': height + 'px',
'left': windowWidth + 'px',
'position': 'absolute',
'font-size': 12 + 'px',
'color': '#0094ff',
'text-align': 'center',
'width': 'auto',
'line-height': 16 + 'px',
'opacity': '0.8'
}).show();
setTimeout(function () { $('div.tipsClass').fadeOut(); }, (time * 1000));
}后台调用JS函数没有问题,现在的问题是多次调用后,点击浏览器上的退回上一步会再次进入showTips()函数。按理应该是只有用户点击按钮才执行。现在的情况求解????????
1\直接将function showTips() 部分代码了写到后台输出中,然后结束输出( Response.End())2\直接用ajax来执行,然后返回结果
可以上一下ajax代码吗?谢了!