views:

165

answers:

1

Hi,

I have a Iframe, and how to pass a javascript vairable to along with a iframe src.

ex:
var param1=test1;

how to pass "param1" value along with the iframe url. and i want to pass like this.

<iframe frameborder=0 src="http://cart.demo.com/c_jp.php?action=param1" name="navigationframe" id="navigationframe" width="220" height="800">

Thanks in advance.

+2  A: 

If you need to pass the JS param value to the url (as you have it in your code) you can try one of the following:

window.frames[navigationframe].location = window.frames[navigationframe].location +      "&param1" = + param1;   

or

document.getElementById(navigationframe).src = document.getElementById(navigationframe).src + "&param1" = + param1;

If this is the only variable you will be "passing" to the QueryString then make sure you format the QueryString properly (if it is the second or N+1 variable prepend '&' if it is the first prepend '?')

andreas