Home > Web Front-end > JS Tutorial > body text

Universal add-to-favorites code supports IE Firefox and other browsers_javascript skills

WBOY
Release: 2016-05-16 19:11:54
Original
1154 people have browsed it

[Ctrl A select all Note: If you need to introduce external Js, you need to refresh to execute
]<script> function addfavorite() { switch(getOs()) { case 1:window.external.addFavorite('http://www.jb51.net','脚本之家 ');break; case 2:window.sidebar.addPanel('脚本之家', 'http://www.jb51.net/', "");break; case 0:alert("您的浏览器也太牛了,我都不知道如何显示了。 唉。");break; } } function getOs() { if(navigator.userAgent.indexOf("MSIE")>0)return 1; if(isFirefox=navigator.userAgent.indexOf("Firefox")>0)return 2; if(isSafari=navigator.userAgent.indexOf("Safari")>0)return 3; if(isCamino=navigator.userAgent.indexOf("Camino")>0)return 4; if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0)return 5; return 0; } </script>
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template