如何在iframe中为目标链接设置目标?

时间:2010-04-21 12:56:45

标签: jquery

在我的index.html代码中我使用jQuery并且有一个id为#button3的链接。

我在index.html中使用过

 $('#button3 a').attr({
                            target: '_top'
                        });

当我从iframe调用index.html作为src时,页面在_self中打开。 我已尝试使用_blank,但仍然在点击链接时,它不会在新页面上打开。

我有这段代码

 //handle click OK button
                $("#button3").click(function(){
                    if (validate()) {
                        submitQuery();
                    }
                });

                        //set the target attribut to return to the parent

                       $('#button3 a').attr('target', '_parent');

和2个函数validate和submitQuery不会随时调用一个链接。

1 个答案:

答案 0 :(得分:1)

正确的set-attribute语法是:

$('#button3 a').attr('target', '_top');