如何在jquery中更改目标框架链接? [英] how to change the target frame link in jquery?

查看:107
本文介绍了如何在jquery中更改目标框架链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的整个网站都有两个框架。带有导航栏的框架和带有主要内容的另一个框架。当我点击链接时,我希望其他帧(内容帧)淡入淡出,我将如何完成此操作?我试过跟随jquery代码。但它使导航框架淡入淡出。我的意思是我将此代码放在导航栏框架页面中,所以当我点击导航栏框架时,此框架正在运行代码,因此此框架页面正在淡入或淡出。如何将内容重定向到另一个框架? jquery中用于更改链接目标的命令是什么?

i have two frame in my whole website. a frame with navigation bar and another frame with main content. when i click on a link, I want the other frame (content frame) to fade in and out, how would I accomplish this? I tried following jquery code. but it made the navigation frame fade in and out. what i mean is i put this code in the navigation bar frame page, so when i click on navigation bar frame this frame is running the code, so this frame page is fading in or out. how can redirect the content to the another frame? what is the command in jquery to change the target of the link?

$(document).ready(function() {

 $("Body").css("display", "none");

    $("Body").fadeIn(2000);

 $("a").click(function(event){
  event.preventDefault();
  linkLocation = this.href;

  $("Body").fadeOut(2000, redirectPage);  
 });

 function redirectPage() {
  window.location = linkLocation;
 }

});


推荐答案

假设您的主框架被称为 frame_main

Assuming that you main frame is called frame_main:

第一个问题是改变身体选择器的上下文,例如

For your first question change the context of your body selector, e.g.

$("body", top.frames["frame_main"].document).fadeOut(2000, redirectPage);

第二个问题,而不是 window.location 你必须使用 top.frames [frameName]。location

And the second question, rather than window.location you have to use top.frames["frameName"].location.

function redirectPage() {
    top.frames["frame_main"].location = linkLocation;
}

编辑:完整示例:

$(document).ready(function() {

    var body = $("body", top.frames["frame_main"].document);

    body.css("display", "none").fadeIn(2000);

    $("a").click(function(event){
        event.preventDefault();
        linkLocation = this.href;

        body.fadeOut(2000, redirectPage);  
    });

    function redirectPage() {
        top.frames["frame_main"].location = linkLocation;
    }
});

这篇关于如何在jquery中更改目标框架链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆