简体   繁体   English

jQuery - Onclick 在 jQuery 中打开链接

[英]jQuery - Onclick open link in jQuery pop

Im looking for a jQuery login that will target specific links (based on class) and will open that link in a popup window?我正在寻找一个 jQuery 登录名,该登录名将针对特定链接(基于类)并将在弹出窗口 window 中打开该链接?

So instead of having to leave the site they get all external content served in a pop-up.因此,他们不必离开网站,而是在弹出窗口中获得所有外部内容。

Does anyone know of such a plugin?有人知道这样的插件吗?

You don't need jQuery for this.为此,您不需要 jQuery。 You can do something like this:你可以这样做:

HTML : HTML

<a href="http://www.example.com" onClick="window.open(this.href, null, ' '); return false;">Click me!</a>

View this sample: http://jsfiddle.net/Davood/MF44t/查看此示例: http://jsfiddle.net/Davood/MF44t/

or you can colorbox plugin: http://colorpowered.com/colorbox/或者你可以使用colorbox插件: http://colorpowered.com/colorbox/

see this page for demo: http://colorpowered.com/colorbox/core/example1/index.html请参阅此页面进行演示: http://colorpowered.com/colorbox/core/example1/index.html

and click on " Outside HTML (Ajax) " link to see demo.并单击“外部 HTML (Ajax)”链接查看演示。

I don't know if I got you correctly, but I guess this could do the trick (I'm not sure I really understood what you want to get)我不知道我是否正确地理解了你,但我想这可以解决问题(我不确定我是否真的理解你想要得到的东西)

<html>
    <head>
        <script src="jquery-1.5.js"></script>
        <script>
         $(
            function() {
                $(".classSpecialLink").each(
                    function() {
                        this.goto = this.href;
                        this.href = "javascript:;";
                    }
                ).click(
                    function() {
                        window.open(this.goto);
                    }
                )
            }
        ); 
        </script>
    </head>
    <body>
        <a href="http://www.google.com" class="classNormalLink">normal link</a><br />
        <a href="http://www.google.com" class="classSpecialLink">special link</a>
    </body>
</html>

ps: by login did you mean plugin? ps:登录是指插件吗?

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

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