当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 网页制作中常用的几段小Javascript代码

Javascript
JavaScript中的Navigator浏览器对象
JavaScript中的Screen屏幕对象
JavaScript中的Window窗口对象
JavaScript中的History历史对象
JavaScript中的Location地址对象
JavaScript中的Document文档对象
JavaScript中的事件处理
JavaScript中的对象化编程
JavaScript框架编程
JavaScript的Cookies
JavaScript表单常用验证集合
javascript 实现的多浏览器支持的贪吃蛇webgame
表现、结构、行为分离的选项卡效果
用JavaScript 判断用户使用的是 IE6 还是 IE7
msn上的tab功能Firefox对childNodes处理的一个BUG
jquery 插件 人性化的消息显示
零基础学JavaScript最新动画教程+iso光盘下载
用jQuery实现检测浏览器及版本的脚本代码
在Javascript类中使用setTimeout
Javascript 写的简单进度条控件

网页制作中常用的几段小Javascript代码


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-28   浏览: 236 ::
收藏到网摘: n/a

收藏本站

以下为引用的内容:
<span style="CURSOR: hand" onClick="window.external.addFavorite('http://www.ruanchen.com','软晨学习网')" title="软晨学习网">收藏本站</span>

或:

以下为引用的内容:
<script Language="JavaScript">
  function bookmarkit()
  {
  window.external.addFavorite('http://www.ruanchen.com','软晨学习网')
  }
  if (document.all)document.write('<a href="#" onClick="bookmarkit()">加入收藏夹</a>')
  </script>

通用的加入收藏夹

以下为引用的内容:
<script type="text/javascript">
// <![CDATA[
function bookmark(){
var title=document.title
var url=document.location.href
if (window.sidebar) window.sidebar.addPanel(title, url,"");
else if( window.opera && window.print ){
var mbm = document.createElement('a');
mbm.setAttribute('rel','sidebar');
mbm.setAttribute('href',url);
mbm.setAttribute('title',title);
mbm.click();}
else if( document.all ) window.external.AddFavorite( url, title);
}
// ]]>
</script>  
<a href="javascript:bookmark()">加入收藏夹</a>

在IE6-7. FF2.0 OP9.0中测试通过

设为首页

以下为引用的内容:
<span onclick="var strHref=window.location.href;this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.ruanchen.com');" style="CURSOR: hand">设为首页</span>

返回页首

以下为引用的内容:

<img src="/imgs/top.gif" onClick="javascript:document.location='#top'" style="cursor:pointer;">