Reputation: 488
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>
Upvotes: 1
Views: 329
Reputation: 15724
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>
Upvotes: 1