html网页代码首页模板(html做网页的代码)

http://www.itjxue.com  2023-02-17 14:27  来源:未知  点击次数: 

HTML设为首页代码怎么写

这里有两种方法将当前页设为你浏览器的主页,一种是将你正在浏览的网页设为首页;另一种是将指定网址设为首页,至于你用哪一种,看你的需要了,各有各适用的场合

方法一:

a onclick="var strHref=window.location.href;this.style.behavior='url(#default#homepage)';this.setHomePage('');" href="javascript:;"设为首页/a/p

方法二:

a title="设为首页" onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('');" href="javascript:;"设为首页/a

注意的是:只有ie浏览器支持代码设置,其他的不行。其他的浏览器可以参考:

怎么样编辑网站首页html模板

如果你做的首页模板不需要调用cms的数据,那么随便弄一个html文件,首页可以设为跟cms不同默认静态页文件后缀不同即可,或者更改虚拟主机的默认首页名称和顺序,比如,你可以在你的虚拟主机上设你的首页为star.html,index.html,star.html排在最前就可以了

html网页模板代码

。。。。

border-width: 0px;

边的宽度为0

border-style

边的类型

vertical-align: top

垂直居上

HTML代码如何实现设置当前页面为首页

不必设置为首页,只需要在连接到首页的连接href改为这个页面就可以了~

如果是浏览器打开的首页,那就是在浏览器设置中更改:(chrome)

(Firefox)

var?homePage?=?{????

??is?:?function(url)?{?//IE判断当前页面是否主页???

????url?=?url?||?window.location.href;????

????if?(document.all)?{????

??????//?????

??????document.body.style.behavior='url(#default#homepage)';????

??????return?document.body.isHomePage(url);????

????}????

????return?false;????

??},????

??set?:?function(url)?{??//除了Chrome之外的FF和IE的设置方法??

????try?{????

??????url?=?url?||?window.location.href;????

??????if?(document.all)?{????

????????if?(!homePage.is(url))?{????

??????????document.body.style.behavior='url(#default#homepage)';????

??????????document.body.setHomePage(url);????

??????????return?homePage.is(url);????

????????}????

????????return?true;????

??????}?else?if?(window.sidebar)?{????

????????if?(window.netscape)?{????

??????????try?{????

????????????netscape.security.PrivilegeManager????

????????????????????.enablePrivilege("UniversalXPConnect");????

??????????}?catch(e)?{??????

?????????????alert("请在浏览器地址栏输入“about:config”并回车"?+????

???????????????"然后将[signed.applets.codebase_principal_support]"?+????

???????????????"设置为“true”,点击“加入收藏”后忽略安全提示,即可设置成功。");????

??????????}????

????????}????

????????var?prefs?=?Components.classes['@mozilla.org/preferences-service;1']????

??????????????????????.getService(Components.interfaces.nsIPrefBranch);????

????????prefs.setCharPref('browser.startup.homepage',url);????

????????return?true;????

??????}????

??????//?Not?support?exception????

??????return?false;????

????}?catch?(e)?{????

??????return?false;????

????}????

??}????

}

对于Chrome暂时没有解决方案,上面的代码兼容IE和FF:

?homePage.set(window.location.href);

(责任编辑:IT教学网)

更多

推荐广告特效文章