Joe Marie
Joe Marie

Reputation: 346

load href to iframe but targetting it in parent window

I have these codes:

<html>
    <head>
        <title>Iframe</title>
    </head>
<body>
    <a href="somepage.html" target="content">SomePage</a><br/>
    <a href="anotherpage.html" target="content">AnotherPage</a><br/>
    <iframe src="" name="content" height="40%" width="100%"></iframe>
</body>
</html>

as you can see I have two links and one iframe,What i need is when I click SomePage.html link, I want the parent window reloads and then the SomePage.html will be loaded in the iframe, is this possible?, Thanks!

EDITED:

I have an Auto-Resizing iframe that only grows on heights and cannot shrink to smaller heights (well that's my problem here, All I want to achieve is the MasterPage like behavior in asp.net.

Upvotes: 1

Views: 792

Answers (1)

iConnor
iConnor

Reputation: 20209

This is possible, you can use localStorage it's not cross fully browser. Quick Example.

$(document).ready(function(){
   if(localStorage.frameURL) {
      $("iframe[name=content]").attr('src', localStorage.frameURL);
   }

   $("[target=content]").click(function() {
     localStorage.frameURL = $(this).attr('href');
     window.location.reload();
   });
});

Upvotes: 1

Related Questions