使用JavaScript将变量传递给一个框架,使用'< a ...' [英] Passing variable to a frame using '<a...' using JavaScript

查看:101
本文介绍了使用JavaScript将变量传递给一个框架,使用'< a ...'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



代码:



<$>

我想将一个变量传递给框架,但我得到了当前页面。 p $ p $ 函数重定向(e){
$('#frame')。show();
document.getElementById('frame')。contentWindow.document.location.href =page.php?var =+ X;
e.preventDefault;
}

< a href =#target =frameonClick =redirect();>< / a>


解决方案

我想我可能已经得到它的工作: http://jsfiddle.net/LrBau/1/

 < a href =#class =redirect-link>重定向< / a> 

< iframe id =frame>< / iframe>

< script>

var X ='testVal';

var redirect = function(){
$('#frame')。show()。attr('src',page.php?var =+ X);
返回false;
};

$('。redirect-link')。click(redirect);

< / script>


I want to pass a variable to the frame but I got the current page.

Code:

function redirect(e){
 $('#frame').show();
 document.getElementById('frame').contentWindow.document.location.href = "page.php?var="+X;         
 e.preventDefault; 
}

<a href="#"  target="frame" onClick="redirect();"></a>

解决方案

I think I may have gotten it working: http://jsfiddle.net/LrBau/1/

<a href="#" class="redirect-link">redirect</a>

<iframe id="frame"></iframe>

<script>

  var X = 'testVal';

  var redirect = function() {
    $('#frame').show().attr('src', "page.php?var=" + X);        
    return false;
  };

  $('.redirect-link').click( redirect );

</script>

这篇关于使用JavaScript将变量传递给一个框架,使用'&lt; a ...'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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