View Full Version : Target a page and load target iframe
deneb87
05-25-2007, 04:33 PM
i've two different section with different layout on my website.
I've to target the other layout loading a specified page in the iframe.
i've tried this:
<a href="/prova/index2.htm" onClick="parent.I1.location.href = '/prova/giochi/magic.htm'" target="_top">
but it load in the iframe the initial page and not magic.htm
solution?
thanks
jscheuer1
05-26-2007, 05:28 AM
Why would there be one link in the href and another in the onclick event? And why one target in the target attribute and another in the onclick event?
Anyways, if you want magic.htm in the iframe named I1, I'd do this:
<a href="/prova/giochi/magic.htm" onclick="parent.frames['I1'].location = '/prova/giochi/magic.htm';return false;" target="I1">
or just:
<a href="/prova/giochi/magic.htm" target="I1">
jscheuer1
05-26-2007, 06:05 AM
I think I may have misunderstood your question. If you want to change the top page and the iframe is on the new top page, you cannot load to it from the link, but you could load to it using a query processed on the new top page:
<a href="/prova/index2.htm?I1=prova%2Fgiochi%2Fmagic.htm" target="_top">
Then on /prova/index2.htm in the body, after the iframe named I1, have it like:
<iframe name="I1" src="about:blank" width="300" height="300" scrolling="auto" frameborder="1"></iframe>
<script type="text/javascript">
function getQval(n, m) {
/* n=name, m=searchString(optional) */
if(!arguments[0]||typeof n!='string')
return null;
var r=new RegExp('[?&;]'+n+'=([^&;#]*)'), m=arguments[1]?m:location.search;
return (m=r.exec(m))? unescape(m[1]) : null;
}
if(getQval('I1'))
window.frames['I1'].location=getQval('I1')
</script>
deneb87
05-26-2007, 08:37 AM
thanks a lot it work =)
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.