i need passing parameters url frame.
example : url - http://mysite.com?var1=2&var2=3
i got 2 frames should open links-
- frame1 -
http://othersite.com?id=<value of var1>
- frame2 -
http://othersite.com?id=<value of var2>
i need build web page opens 2 url in 2 frames. in order pass parameter 2 iframe have:
using url open : http://mysite.com?var1=242
the page contain code:
<frame name="frame1" src="http://myapp?id=<value of var1>#tab1"> <frame name="frame2" src="http://myapp?id=<value of var1>#tab2">
how ? put value of 242 in src of each frame ?
new js.
thanks,
paka.
just leave src
of frame
s empty/out in html, add script head
section of frameset
page:
window.onload = function () { var n, key, vars = {}, searchstring = window.location.search; searchstring = searchstring.replace(/^\?/, '').split('&'); (n = 0; n < searchstring.length; n++) { key = searchstring[n].split('='); vars[key[0]] = key[1]; } window.frames['frame1'].frameelement.src = 'http://myapp?id=' + vars.var1 + '#tab1'; window.frames['frame2'].frameelement.src = 'http://myapp?id=' + vars.var2 + '#tab2'; }
also search string supposed last part of url. if id
s not 242#tab1
, need way:
window.frames['frame1'].frameelement.src = 'http://myapp#tab1?id=' + vars.var1;
if setting src
of frameelement
doesn't work you, can set location of window
in frame
:
window.frames['frame1'].location.href = 'http://myapp#tab1?id=' + vars.var1;
Comments
Post a Comment