简体   繁体   English

如何在模式窗口而不是新选项卡中打开锚点

[英]How to open anchor in a modal window, not a new tab

This site demos Social Sharing code such as 'share to Facebook'. 该站点演示了“社交共享”代码,例如“共享给Facebook”。 Here, clicking the links on the left opens the sharing in a modal window. 在这里,单击左侧的链接可在模式窗口中打开共享。 Their code: 他们的代码:

<!-- Facebook -->
<a href="http://www.facebook.com/sharer.php?u=https://simplesharebuttons.com" target="_blank">
    <img src="https://simplesharebuttons.com/images/somacro/facebook.png" alt="Facebook" />
</a> 

I want a similar effect and I have the following anchor but this opens in a new tab . 我想要类似的效果,并且具有以下anchor但这会在新选项卡中打开。 I want it to open in a modal window : 我希望它在模式窗口中打开

<a href="http://www.facebook.com/sharer.php?u=http://www.idybrand.com/" title="Share on Facebook" target="_blank" >
    <img alt="Share on Facebook" width="40" height="40" src="img/social_media/facebook.svg">
</a>

How can I achieve this please? 请问我该如何实现? Possibly using Bootstrap? 可能使用Bootstrap吗?

Replace your code with this:: 用以下代码替换您的代码::

<a href="http://www.facebook.com/sharer.php?u=http://www.idybrand.com/" title="Share on Facebook" target="popup" onclick="window.open('http://www.facebook.com/sharer.php?u=http://www.idybrand.com/','popup','width=600,height=600'); return false;">
<img alt="Share on Facebook" width="40" height="40" src="img/social_media/facebook.svg">
</a>

It will work.. 会的..

You can use this. 您可以使用它。 I hope it helps. 希望对您有所帮助。

<a onclick="window.open('https://www.facebook.com/','mywindow','width=640,height=360')" href="javascript:void(0)"><button>Click FB</button></a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM