我想创建一个共享按钮以共享我的blogger博客中的报价。
例如
<blockquote>"Imagination is more important than knowledge."
--Albert Einstein</blockquote>
<share_button>
<blockquote>"Life is a preparation for the future; and the best preparation for the future is to live as if there were none."
--Albert Einstein</blockquote>
<share_button>
[访问者单击共享按钮时,将删除引号和发布URL。
并且单击共享按钮后,默认的Android共享应用程序列表打开,用户可以选择所需的应用程序共享报价。
编辑
<blockquote>"Imagination is more important than knowledge."
--Albert Einstein</blockquote>
<button class="shareBtn">Share Blockquote</button>
<blockquote>"Life is a preparation for the future and the best preparation for the future is to live as if there were none."
--Albert Einstein</blockquote>
<button class="shareBtn">Share Blockquote</button>
<blockquote>"Remember not only to say the right thing in the right place, but far more difficult still, to leave unsaid the wrong thing at the tempting moment."
--Benjamin Franklin</blockquote>
<button class="shareBtn">Share Blockquote</button>
<blockquote>"You don't have to hold a position in order to be a leader."
--Henry Ford</blockquote>
<button class="shareBtn">Share Blockquote</button>
您可以使用Web Share API
<button id="shareBtn">Share Blockquote</button>
<script>
//<![CDATA[
var shareButton = document.getElementById('shareBtn');
var title = document.title;
var text = document.querySelector('blockquote').textContent;
var url = window.location.href;
shareButton.addEventListener('click', function () {
if (navigator.share) {
navigator.share({
title: title,
text: text,
url: url
});
}
});
//]]>
</script>