Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opening share content inline instead of new window/tab? #39

Closed
mtbpm opened this issue Jan 12, 2022 · 3 comments
Closed

Opening share content inline instead of new window/tab? #39

mtbpm opened this issue Jan 12, 2022 · 3 comments
Labels
question A question about the product

Comments

@mtbpm
Copy link

mtbpm commented Jan 12, 2022

hello nick

we like your plugin and are considering working with it. could you please share your opinion on the following:

current shareon behaviour

  • klick a share button
  • new window/tab is opened with preloaded share-content (user leaves current page / context)

desired shareon behaviour

  • klick a share button
  • inline element (e.g. div or iframe) is populated with preloaded share-content (user stays on current page)

is this impossible/restricted by CORS policies or other technical reasons?

thank you

ps.: i understand that is currently not part of shareon's features, just asking if you think this could be possible.

@kytta
Copy link
Owner

kytta commented Feb 11, 2022

Hi @mtbpm,

sorry for taking so long with my answer. Theoretically, you could use an <iframe> to display the share dialogue in-page. However, I don't know if this would work properly. AFAIK, many browsers block 3rd-party <iframe>s, and some website providers don't allow such embedding because of strict Cross-Origin policies. Heck, even opening pop-ups in new windows (instead of the new tabs) is now considered bad :(

You could experiment with it, of course. Shareon doesn't offer customizing listeners and link hrefs. You could load and initialize Shareon, and then convert listeners to something new. For example:

<div class="shareon">
  <a class="twitter"></a>
</div>
// TODO: import Shareon
// TODO: initialize Shareon

for (const container of querySelectorAll('.shareon')) {
  for (const button of container.children) {
    const url = button.getAttribute("href");
    button.setAttribute("href", "#");
    button.addEventListener("click", function () {
      // open <iframe> with url
    })
  }
}

I'm afraid, I can't help any further here 😅

@kytta kytta added the question A question about the product label Feb 11, 2022
@kytta kytta changed the title question: opening share content inline instead of new window/tab? Opening share content inline instead of new window/tab? Feb 11, 2022
@kytta
Copy link
Owner

kytta commented Feb 13, 2022

I'll close the issue, but you're free to ask further questions or opening new issues for discussion!

@kytta kytta closed this as completed Feb 13, 2022
@mtbpm
Copy link
Author

mtbpm commented Feb 15, 2022

hello kytta, thanks a lot for the details on this. i will try it out and let you know if it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question A question about the product
Projects
None yet
Development

No branches or pull requests

2 participants