반응형
#즐겨찾기
<a href="javascript:bookmark();" id="favorite">즐겨찾기</a>
function bookmark(){
window.external.AddFavorite('홈페이지주소', '즐겨찾기시입력될이름')
}
*ie의 경우 Ctrl+D 로 확인되는 창이 뜬다.
//즐겨찾기
$('#favorite').on('click', function(e) {
var bookmarkURL = window.location.href;
var bookmarkTitle = document.title;
var triggerDefault = false; if (window.sidebar && window.sidebar.addPanel) {// Firefox version < 23
window.sidebar.addPanel(bookmarkTitle, bookmarkURL, '');
} else if ((window.sidebar && (navigator.userAgent.toLowerCase().indexOf('firefox') > -1)) || (window.opera && window.print)) {
// Firefox version >= 23 and Opera Hotlist
var $this = $(this);
$this.attr('href', bookmarkURL);
$this.attr('title', bookmarkTitle);
$this.attr('rel', 'sidebar');
$this.off(e); triggerDefault = true;
} else if (window.external && ('AddFavorite' in window.external)) {
// IE Favorite
window.external.AddFavorite(bookmarkURL, bookmarkTitle);
} else {
// WebKit - Safari/Chrome
alert((navigator.userAgent.toLowerCase().indexOf('mac') != -1 ? 'Cmd' : 'Ctrl') + '+D 키를 눌러 즐겨찾기에 등록하실 수 있습니다.');
}
return triggerDefault;
});
728x90
반응형
'JS & jQuery' 카테고리의 다른 글
wing 배너(fix) (0) | 2022.01.17 |
---|---|
top 버튼& down 버튼 (0) | 2022.01.17 |
스크롤 제어 (0) | 2022.01.17 |
체크박스 (0) | 2022.01.17 |
앵커태그(anchor tag) (0) | 2022.01.14 |