JavaScript中如何重定向url? 两个不同的文件夹,但是里面的文件名相同比如说我现在200808/a.html这个文件上,我想跳到200809/a.html上. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你把时间当成1个变量比如200808.html ,200809.htmlselect的ID是sel_idvar abc=document.getElementId("sel_id").value;var url=abc+".html"; 楼上正解,再加一个document.location.href="构造的URL"; 可能我刚才没说清楚:查询其他月份: <select id="permonth" name="permonth"> <option value="9" selected="selected">2008年9月</option> <option value="8">2008年8月</option> </select> <input type="submit" name="submit" value="查询" onclick="calu()" />当前页面如果是../20080930/a1.html我选择2008年8月时,我想让它跳到../20080831/a1.html 在option后面加一个value,然后用js判断实现跳转就可以了吧 我alert出来地址了,地址是正确的。可跳转不了,报url不正确.我的html是aspx自动生成的。郁闷! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>无标题文档</title></head><body><script type="text/javascript">function $(id){ return document.getElementById(id);}function calu(){ var url = window.location.href; var month = $("permonth").options[$("permonth").selectedIndex].value; month = month.length < 2 ? "0" + month : month; url = url.replace(/(^.*\/20\d{2})(\d{2})(\d{2}\/.*.htm[l]$)/, "$1" + month + "$3"); window.location.href = url;}</script><select id="permonth" name="permonth"> <option value="9" selected="selected">2008年9月</option> <option value="8">2008年8月</option> </select><input type="submit" name="submit" value="查询" onclick="calu()" /></body></html> JS 跨页面验证非空 无法给HTML标签添加两个属性 表单提交验证怎么实现 提问:两个菜鸟问题,哪位老大能帮我解决一下。100分送上。 高手快来啊! 当前页屏蔽菜单栏工具栏地址栏状态栏的问题 两个方法的区别 当关闭浏览器(正常关闭或异常关闭)时,必需执行一个操作 如果radio对象组只有一个,怎样判断是否checked? js animate 渐变隐藏 圖片怎樣隨瀏覽視窗向下移動 如何实现li菜单的上一页和下一页?
比如200808.html ,200809.html
select的ID是sel_id
var abc=document.getElementId("sel_id").value;
var url=abc+".html";
<select id="permonth" name="permonth">
<option value="9" selected="selected">2008年9月</option>
<option value="8">2008年8月</option>
</select>
<input type="submit" name="submit" value="查询" onclick="calu()" />当前页面如果是../20080930/a1.html
我选择2008年8月时,我想让它跳到../20080831/a1.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head><body>
<script type="text/javascript">
function $(id){
return document.getElementById(id);
}
function calu(){
var url = window.location.href;
var month = $("permonth").options[$("permonth").selectedIndex].value;
month = month.length < 2 ? "0" + month : month;
url = url.replace(/(^.*\/20\d{2})(\d{2})(\d{2}\/.*.htm[l]$)/, "$1" + month + "$3");
window.location.href = url;
}
</script><select id="permonth" name="permonth">
<option value="9" selected="selected">2008年9月</option>
<option value="8">2008年8月</option>
</select>
<input type="submit" name="submit" value="查询" onclick="calu()" /></body>
</html>