网站设为首页,加入收藏夹
<a href=# onClick="this.style.behavior='url(#default#homepage)';this.setHomePage('URL');event.returnValue=false;">设为首页</a>
URL就是你要设定的网址地址
要设置当前网页的地址为首页,你可以这样:
<a href=# onClick="this.style.behavior='url(#default#homepage)';this.setHomePage(document.location.href);event.returnValue=false;">设为首页</a>
上述方法采用javascript的document.location对象的href属性来获得当前网页的全路径。
同理,如果您只想将当前网页所在的域名地址设为首页,您只需将document.location.href改为document.location.host即可。示例如下:
<a href=# onClick="this.style.behavior='url(#default#homepage)';this.setHomePage(document.location.host);event.returnValue=false;">设为首页</a>
说明:如果当前网页的地址为:http://www.05371.com/indexnews.htm,则会将当前网页的域名地址(www.05371.com)设为首页。
加入到收藏夹中的实现方法为:
<a href="Javascript:window.external.addFavorite('http://www.05371.com','易远网络')">加入收藏</a>
举一反三,与上面设为首页的方法一样,如果您要将当前网页加入收藏,而当前网页的网址不确定,您可以采用以下方法:
<a href="Javascript:window.external.addFavorite(document.location.href,document.title)">加入收藏</a>
其中的document.title为自动获取当前网页的标题的javascript代码。
用到的代码
document.location.host //获取网页域名地址
document.location.href //获取网页完整路径
document.title //获取网页的标题
<a target=_top href=javascript:window.external.AddFavorite('http://www.05371.com';,'易远网络')>加入收藏</a>
<a href=# onClick="this.style.behavior='url(#default#homepage)';this.setHomePage('www.05371.com');">设为首页</a>
<P><a target=_top href=javascript:window.external.AddFavorite('<A href="http://www.05371.com/" target=_blank>http://www.05371.com</A>#39;,'<A class=Channel_KeyLink href="http://www.05371.com/">济宁网站建设</A>易远网络')>加入收藏</a></P>
<P><BR><a href=# onClick="this.style.behavior='url(#default#homepage)';this.setHomePage('www.05371.com');">设为首页</a></P>
图片链接
<a style="cursor:hand" οnclick="this.style.behavior=’url(#default#homepage)’;
this.setHomePage(’http://05371.com/bookmark-favorites.php’);">
<img width=16 height=16 border=0 src="data:images/house.png">
<u> Set as Home Page</u></a>
1.文字型:
<a οnclick="this.style.behavior=’url(#default#homepage)’;this.setHomePage(’http://www.05371.com’);" href="#">設為首頁</a>
範例:
設為首頁
2.按鈕型:
<input TYPE="button" VALUE=" 設為首頁 " οnclick="this.style.behavior=’url(#default#homepage)’;this.setHomePage(’http://www.05371.com’);" href="#">
离开时自动提示设为首页
<body οnunlοad="BASEBody.style.behavior=’url(#default#homepage)’;if(!(BASEBody.isHomePage(’http://ha321.com')))BASEBody.setHomePage(’http://www.05371.com/’);">
-------------------------------------------------------------
打开页面时自动弹出窗口询问是否设为首页 字串7
将以下代码放在<head></head>之间:
<script language="javascript">
function myhomepage(){
this.homepage.style.behavior=’url(#default#homepage)’;this.homepage.sethomepage(’http://www.ha321.com’);
}
</script>
<p align="center"><a href="http://05371.com" name="homepage"
οnclick="myhomepage();"></a>
再将下面代码加入<body>内:
οnlοad="myhomepage();"
即:<body οnlοad="myhomepage();">
------------------------------------------------------------------------------
鼠标指向时提示设为首页
将下列代码插入<body>区中:
<A href="http://www.05371.com/" οnmοuseοver="this.style.behavior=’url(#default#homepage)’;this.setHomePage(’http://www.05371.com’);" target="_blank">设为首页</A>
-------------------------------------------------------------------------------
关闭当前窗口的功能
这里我们可以先输入用来标示的文字“关闭窗口”,用鼠标拖动选中它,在“Link”输入框中键入“/”,同时切入源代码窗口,在链接代码中键入该事件-οnclick=“javascript:window.close(); return false;”。
字串2
完整的代码为:<a href=“/”οnclick=“javascript:window.close(); return false;”>关闭窗口</a>
以上内容转摘自:(易远网站技术网)→http://www.05371.com 更多精彩内容和详细出处请参考:http://www.05371.com/content/2009619121521.html
网站设为首页,加入收藏夹相关推荐
- 设为首页+加入收藏夹+打印网页
[code]<a href=# onClick="this.style.behavior='url(#default#homepage)';this.setHomePage ('htt ...
- javascript 设为首页 | 加入收藏夹 JS代码
我们介绍一个可兼容所有浏览器的加入收藏代码代码,大概原理是这样的我们根据获取用户navigator.userAgent.toLowerCase()信息来判断浏览器,根据浏览器是否支持加入收藏js命令, ...
- php 设为首页 收藏_如何在网站上添加“设为首页”“加入收藏”
很多网站顶部都有"设为首页""加入收藏"功能,当用户点击"设为首页"后,这个网站就会成为用户浏览器默认打开的网页页面. 当用户点击" ...
- 设为首页 加入收藏 html,[javascript]js设为首页和加入收藏夹代码
我们见过很多网站的顶部都有这样的功能,设为首页和加入收藏的功能. 其实,这些功能的实现也都是js代码实现的,今天我为另一个网站添加了这样的代码.点击测试有效.代码如下. js代码: //tmac 设为 ...
- Js调用游览器的外部方法(设首页,收藏夹等游览器操作)
在js中可以操作游览器的方法.用window对象的external属性掉方法.如: (window.external 对象详解 允许访问由 Microsoft® Internet Explorer 浏 ...
- 设为首页 和 收藏本站js代码 兼容IE,chrome,ff
设为首页 和 收藏本站js代码 兼容IE,chrome,ff //设为首页 function SetHome(obj,url){ try{ obj.style.behavior='url(#defau ...
- JS控制字体大小中、设为首页、收藏本站功能、超链接去掉颜色
设置字体大小中小JS <script type="text/javascript">function SetFont(size) {var divBody = docu ...
- 网站“设为首页”代码,“加入收藏”代码
<a href="#" class="word_white" οnclick="this.style.behavior='url(#defaul ...
- MVC3.0 将网站设为首页和加为收藏的实现(IE/Firefox)
设置为首页的方法为: <a href=# onClick="this.style.behavior='url(#default#homepage)';this.setHomePage( ...
最新文章
- Hibernate与 MyBatis的比较
- 转发离线安装 Android Studio 更新
- 删除同域名所有cookies_淘宝自动登录2.0,新增Cookies序列化
- 二叉树后序遍历_LeetCode算法145. 二叉树的后序遍历
- IOS学习笔记之十七 (NSDate、NSDateFormatter、NSCalendar、NSDateComponents、NSTimer)
- android 倒计时封装,react native中的聊天气泡及timer封装成的发送验证码倒计时
- sklearn机器学习实例
- 判断系统是64位还是32位的bat方法
- 开发实现物理加速度移动_Cocos Creator 3D 物理模块介绍
- ## CSP 201409-1相邻数对(C语言)(100分)
- cs231n学习笔记-激活函数-BN-参数优化
- 项目的webinf文件在哪_PMP章节练习(第四章:项目整合管理)
- arcgis下载地址
- 武汉大学计算机学院电子与通信工程,武汉大学电子信息学院信息与通信工程
- 【K8S etcd篇】部署etcd 3.4.14 集群
- 编译php7.1.4出现 undefined reference to isfinite
- 安卓手机版微信聊天加密软件 悬浮窗版本
- PXE自动安装Linux系统
- max3490esa_MAX3096ESE+T_maxim芯片后缀tg16是什么意思
- 计算机视觉外语论文翻译,图像处理-毕设论文外文翻译(翻译+原文)