でお気に入り追加するとき、
http://example.com/
にお気に入り登録させる仕組みを作りたいのですが、
方法を教えてください。
javascriptとかですかね。
もしくはブラウザのお気に入りアクションで取得する値を変更する、
htmlの書き方とかあるでしょうか?
ie/firefox共用のスクリプトだと都合が良いのですが。。。
http://www.sky.sannet.ne.jp/masapine/java_favorite.html
を参考にされると良いと思います。ボタンなら、
<INPUT type="button" value="お気に入りに追加" onClick="javascript:window.external.AddFavorite('http://example.com/html','お気に入りの名前')">
という感じで可能です。
度々済みません。
ie/firefox共用となるとブラウザを判別する仕組みが必要なので少々複雑になりますが、
http://www6.atwiki.jp/uriaplus/pages/39.html
のような方法で可能です。
<script language="JavaScript" type="text/JavaScript"> if(navigator.userAgent.indexOf("MSIE") > -1){ // IE の場合 document.writeln('<!-'+'-[if IE]>'); //スクリプトが使えない環境を完全にはじく document.writeln('<p>'); document.writeln('<input type="button" value="お気に入りに追加"'); document.writeln(' onclick="window.external.AddFavorite(\'http://example.com/\',\'お気に入り名\')">'); document.writeln('<'+'/p>'); document.writeln('<![endif]-'+'->'); } else if(navigator.userAgent.indexOf("Firefox") > -1){ // Firefox の場合 document.writeln('<p>'); document.writeln('<input type="button" value="ブックマークに追加"'); document.writeln(' onclick="window.sidebar.addPanel(\'ブックマーク名\',\'http://example.com/\',\'\');">'); document.writeln('<'+'/p>'); } else { //該当なし void(0); //何もしない } </script>
ありがとうございます。
ieのみですね