Multiple Iframes Sending One Request To The Same Src
I was wondering if there was a way to have say 3 iframes load the same resource (http://myservice.php) with ONLY ONE request from the iframe. The myservice.php returns an Html Docu
Solution 1:
I think you need to use javascript for this.
Take your frames and give each of them a different id:
<iframe name="iframe1"id="f1" src="old.html"></iframe>
<iframe name="iframe2"id="f2" src="old.html"></iframe>
<iframe name="iframe3"id="f3" src="old.html"></iframe>
Call a function:
<ahref="#"onClick="multipleFrames('new.html');">change iframes</a>
It would be best to pass the URL in the function. This makes your code more reusable.
Then make a function to which you pass the url (u).
functionmultipleFrames(u){ //urlvar frames=window.frames;
for (var i=1; i<3; i++){
var frame="f"+i;
document.getElementById(frame).src = u;
}
}
If you have a differing amount of iframes in different places you could pass the number of iframes as well
<ahref="#"onClick="multipleFrames('new.html','3');">change iframes</a>
functionmultipleFrames(u,n){ //url, number of iframesvar frames=window.frames;
var total=n+1;
for (var i=1; i<total; i++){
...
}
Post a Comment for "Multiple Iframes Sending One Request To The Same Src"