这是主题变换颜色的javascript,但是当我不断的点周变换时,就会出现hrefID字段值:10?NaN?NaN?NaN?NaN长过系统允许长度20!,当我把 AlertMessageBox 和 showPop方法的?rand传参去掉就没有问题了。请问,他在这里加rebd这个传参有什么意图呢?我想他概然加这个必有他的用意。还有一个问题,Math.round()是返回最接近指定值的数字吧?
var DispClose = true;
function AlertMessageBox(Messages) {
var rebd = Math.round() * Math.round();
DispClose = false;
window.location.href = location.href + "?" + rebd;
alert(Messages);
} function showPop() {
var rebd = Math.round() * Math.round();
showPopWin('个人设定', '../UserSet.aspx?rand=' + rebd, 400, 255, AlertMessageBox, true); }
function StyleSet() {
var rebd = Math.round() * Math.round();
var url="<%=Page.ResolveClientUrl("~/")%>StyleSet.aspx?rand="+rebd;
showPopWin('主题设置', url, 400, 130, AlertMessageBox, true); }
function showPopWin(Title, url, width, height, returnFunc, showCloseBox, showScrolling, openwinattributes) {
//动态插入iframe
var scrolling = "no";
gattributes = openwinattributes;
if (showScrolling!=null&&showScrolling==true)
scrolling = "auto";
var iframestring = '<iframe src="'+url+'" style="width:100%;height:100%;background-color:transparent;" scrolling="'+scrolling+'" frameborder="0" allowtransparency="true" id="popupFrame" name="popupFrame" width="100%" height="100%"></iframe>';
gpopBodyBox.innerHTML = iframestring;
gPopFrame = document.getElementById("popupFrame");
width = width+30;
document.getElementById("popupTitle").innerHTML = Title;
// show or hide the window close widget if (showCloseBox == null || showCloseBox == true) {
document.getElementById("ext-gen59").style.display = "block";
} else {
document.getElementById("ext-gen59").style.display = "none";
} gPopupIsShown = true;
disableTabIndexes();
gPopupMask.style.display = "block";
gPopupContainer.style.display = "block"; centerPopWin(width, height);
gPopupContainer.style.width = width + "px";
gPopFrame.style.height = height+"px"; setMaskSize(); //gPopFrame.src = url;
gReturnFunc = returnFunc;
// for IE
// if (gHideSelects == true) {
// hideSelectBoxes();
// }
showOrHideControl(false);
window.setTimeout("setPopTitle();", 600);
}
var DispClose = true;
function AlertMessageBox(Messages) {
var rebd = Math.round() * Math.round();
DispClose = false;
window.location.href = location.href + "?" + rebd;
alert(Messages);
} function showPop() {
var rebd = Math.round() * Math.round();
showPopWin('个人设定', '../UserSet.aspx?rand=' + rebd, 400, 255, AlertMessageBox, true); }
function StyleSet() {
var rebd = Math.round() * Math.round();
var url="<%=Page.ResolveClientUrl("~/")%>StyleSet.aspx?rand="+rebd;
showPopWin('主题设置', url, 400, 130, AlertMessageBox, true); }
function showPopWin(Title, url, width, height, returnFunc, showCloseBox, showScrolling, openwinattributes) {
//动态插入iframe
var scrolling = "no";
gattributes = openwinattributes;
if (showScrolling!=null&&showScrolling==true)
scrolling = "auto";
var iframestring = '<iframe src="'+url+'" style="width:100%;height:100%;background-color:transparent;" scrolling="'+scrolling+'" frameborder="0" allowtransparency="true" id="popupFrame" name="popupFrame" width="100%" height="100%"></iframe>';
gpopBodyBox.innerHTML = iframestring;
gPopFrame = document.getElementById("popupFrame");
width = width+30;
document.getElementById("popupTitle").innerHTML = Title;
// show or hide the window close widget if (showCloseBox == null || showCloseBox == true) {
document.getElementById("ext-gen59").style.display = "block";
} else {
document.getElementById("ext-gen59").style.display = "none";
} gPopupIsShown = true;
disableTabIndexes();
gPopupMask.style.display = "block";
gPopupContainer.style.display = "block"; centerPopWin(width, height);
gPopupContainer.style.width = width + "px";
gPopFrame.style.height = height+"px"; setMaskSize(); //gPopFrame.src = url;
gReturnFunc = returnFunc;
// for IE
// if (gHideSelects == true) {
// hideSelectBoxes();
// }
showOrHideControl(false);
window.setTimeout("setPopTitle();", 600);
}
rebd这个传参有什么意图呢 这个相当于 每次请求多传一个值,以便获取请求链接的最新内容(他写的有问题)
Math.round() 应该为 Math.random()吧? round 是四舍五入。 random 是产生随机数
var rebd = Math.round() * Math.round();
DispClose = false;
window.location.href = location.href + "?" + rebd; alert(Messages);
}你这么用,当然是要出现那个错误了。
第一次差不多是好的。样子大概是这样 a.aspx?rand=10
第二次,就成了a.aspx?rand=10?10
第三次,就成了a.aspx?rand=10?10?10
自然出错。因为URL传参只允许一个?应该在JS的开始,用一个变量存储当前页地址,
var theforever_URL=window.location.href;
然后再:
function AlertMessageBox(Messages) {
var rebd = Math.round() * Math.round();
DispClose = false;
window.location.href = theforever_URL + "?" + rebd; alert(Messages);
}