<html xmlns:rdl>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>WEB开发笔记——JS获取判断浏览器的默认首页</title>
<style>
@media all {
rdl/:homepage {behavior:url(#default#homepage);}
}
</style>
<script>
var oHomePage,oCodeDiv,oURL;
var sHomePage;
function rdl_Verify(){
var sHomePage=oURL.value;
var bIs=oHomePage.isHomePage(sHomePage);
with (oCodeDiv) if (bIs) innerText=sHomePage+"是您的默认主页"; else innerText=sHomePage+"不是您的默认主页";
}
function rdl_Set(){
var sHomePage=oURL.value;
oHomePage.setHomePage(sHomePage);
}
function window.onload(){
oHomePage=document.all("idHomePage");
oCodeDiv=document.all("idCodeDiv");
oURL=document.all("idURL");
}
</script>
</head>
<body>
<rdl:homepage id="idHomePage" />
<table><tr>
<td><input type=text size=30 value="http://www.#.com/" id=idURL></td>
<td><input type=button value=" 检测 " οnclick="rdl_Verify();"></td><td><input type=button value=" 设置 " οnclick="rdl_Set();"></td>
</tr></table>
<br>
<br>
<div id=idCodeDiv>请确认输入框内的url地址然后点击「检测」按钮。</div>
<br> <br> <br>
</body>
</html>
检测或设置是否为默认首页
最新推荐文章于 2024-11-14 15:33:48 发布