Iframe src based on javascript variable value
I have an iframe and how can I pass javascript that can be used along with the iframe src.
ex:
var param1=test1;
how to pass the "param1" value along with the iframe url. and I want to go 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 source to share
1 answer
If you need to pass the JS parameter value to the url (as you have in your code), you can try one of the following:
window.frames[navigationframe].location = window.frames[navigationframe].location + "¶m1" = + param1;
or
document.getElementById(navigationframe).src = document.getElementById(navigationframe).src + "¶m1" = + param1;
If this is the only variable you will "pass" to the QueryString, then make sure you format the QueryString correctly (if it is a second or N + 1 variable, add "&" if this is the first prefile? ")
+3
a source to share