Reputation: 488
As the title indicate I would like to pass a variable with javascript but in a frame In the past I have this code :
<a href="page.php" target="frame" onClick="$('#frame').show()">
Now I want to pass a variable, the code below can pass the variable but in another window but I want it in the same frame.
<a href="page.php" target="frame" onClick="location.href=this.href+'?var='+X;">
Upvotes: 1
Views: 1502
Reputation: 15724
I think you maybe able to use:
document.getElementById('frame').contentWindow.location.href...
to change the href of the frame (and pass your variable), but I'm pretty sure it will require a refresh if you're using a query string.
Perhaps if you append a hash (#var=something
) instead of a query string that will work without the refresh?
Note that this probably won't work at all if you're doing your frame stuff across domains.
Upvotes: 2