① js如何改變指定窗口頁面的鏈接
document.location.href="url";//不以新窗口打開
window.location.href="url";//不以新窗口打開
window.open("url");//新窗口打開
② javascript如何替換瀏覽器地址
這個用正則是關鍵,jQuery在這里只是雞肋
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>無標題文檔</title>
<script language="javascript">
function urlchange()
{
var str=document.getElementById('str').value
var rstr=document.getElementById('rstr').value
str=str.replace(/word=\w{3}/igm,'word='+rstr)
document.getElementById('cstr').value=str
}
</script>
</head>
<body>
<label>要替換的url<input type="text" id="str" size="100" value="http://..com/q?ct=17&pn=0&tn=ikask&rn=10&word=bbb&cm=1" /></label><br>
<label>要替換的字元<input type="text" id="rstr" value="dkf" /></label><br>
<input type="button" value="替換" onClick="urlchange()" /><br>
<label>替換結果<input type="text" id="cstr" size="100" value="" /></label>
</body>
</html>
③ js 動態改變background:url()值
可以復用字元串拼接的方法將變數傳到制url中。
1、新建html文檔,在body標簽中添加一個div標簽,為這個div標簽設置一個北京圖片,然後引入jQuery文件:
④ Js中如何修改頁面的地址
低階:
用錨點。
location.hash = 'a';
然後監聽hashchange事件,進行頁面渲染。由於hash值發生變化,效果內相當於切換頁面,容支持F5刷新(不過需要處理hash值)。對於不支持hashchage的瀏覽器得用定時器去刷hash值以監控其變化。
高階:
HTML5中對history進行了完善,可以搜索pushState以了解相關知識。可以做到頁面不刷新修改URL地址,並觸發事件,JS監聽事件起ajax就可以了。
⑤ JS問題 如何在JS中修改<URL>中param的值
用location.href.substring(location.href.indexOf("?") + 1)取url存入queryString,然後parameters=queryString.split("&"),循環parameters,
取等號位置pos = parameters[i].indexOf('=');if(pos == -1) { continue; }
取name和value
paraName = parameters[i].substring(0, pos);
paraValue = parameters[i].substring(pos + 1);
if(paraName == retStr) {
return unescape(paraValue);
}
之後可以根據code=返回的值,用replace("",「cdoe=456」內)替換,不知道你是不是要這樣容的
⑥ javascript 如何不刷新頁面改變url參數
可以使用:window.history.pushState,目前IE9之前不支持此方法