ignore the error message its nothing to fear about try this code as a reference and change your code accordingly
var anchors = document.querySelectorAll('.sharer');
for(var z = 0; z < anchors.length; z++) {
anchors[z].addEventListener('click', function(e) {
//stop the default click action
e.preventDefault();
// grab the base sharing URL
var URL = e.target.getAttribute('data-url');
// grab the name we want to give the window (parameter 2 on window.open)
var windowName = e.target.getAttribute('data-windowName');
// Grab parameter 3 for window.oprn (window settings)
var windowSettings = e.target.getAttribute('data-settings');
// call window.open
window.open(URL + window.location.href, windowName, windowSettings);
}, false);
}
<h2>Won't work on Stack Overflow due to sandbox so may need tweaking your side</h2>
<a class="sharer" href="http://www.facebook.com/share.php?u=https://stackoverflow.com/questions/64640807/share-facebook-or-line-with-onclick-function-but-get-seo-problem-links-are-not" data-url="http://www.facebook.com/share.php?u=" data-windowName="" data-settings="menubar=no,toolbar=no,resizable=no,scrollbars=yes,height=700,width=550" title="Facebook Share" aria-label="Facebook Share">Facebook</a>
<a class="sharer" href="http://line.naver.jp/R/msg/text/?Page title%0Ahttps://stackoverflow.com/questions/64640807/share-facebook-or-line-with-onclick-function-but-get-seo-problem-links-are-not" data-url="http://line.naver.jp/R/msg/text/?Page title%0A" data-windowName="Share with Line" data-settings="height=700,width=550" title="Line Share" aria-label="Line Share">Line</a>
<h2>fallback behaviour</h2>
<p>The below shows how the link behaves with no javascript</p>
<a href="http://www.facebook.com/share.php?u=https://stackoverflow.com/questions/6464080