我已經編寫了一個成功爲以下任何瀏覽器(IE,Firefox和Opera)創建書籤的代碼。單擊瀏覽器書籤時運行JavaScript代碼
<script language="JavaScript" type="text/javascript">
function bookmark()
{
var title = 'Google';
var url = 'http://google.com';
if (document.all)// Check if the browser is Internet Explorer
window.external.AddFavorite(url, title);
else if (window.sidebar) //If the given browser is Mozilla Firefox
window.sidebar.addPanel(title, url, "");
else if (window.opera && window.print) //If the given browser is Opera
{
var bookmark_element = document.createElement('a');
bookmark_element.setAttribute('href', url);
bookmark_element.setAttribute('title', title);
bookmark_element.setAttribute('rel', 'sidebar');
bookmark_element.click();
}
}
</script>
現在我希望我的書籤運行一段JavaScript代碼,而不是在用戶點擊它時瀏覽Google。
作品在IE11謝謝 – Xeltor 2014-07-08 15:21:27