manan2809
manan2809

Reputation: 29

How to retain iframe src after refreshing the parent page using JavaScript or jQuery?

I am designing an application in ASP.NET which has a Master Page and a iframe. When I click on a link within the Master Page, the link is opened in the iframe, but if I refresh the parent page the iframe loses it's source and returns a blank frame.

How can I retain the iframe src attribute after refreshing the page like Parallel's Plesk Panel?

Upvotes: 2

Views: 1381

Answers (1)

Jeremy J Starcher
Jeremy J Starcher

Reputation: 23863

There are a couple of ways to temporary store the URL of the iframe and then retrieve it on the next page reload.

  1. Store it as a cookie
  2. Use localStorage
  3. Use window.name -- er, no. Ha. Just kidding. That is a bad hack.
  4. Use one of the small packages that manage localStorage and default back to cookies if it must.

You might want to read HTML5 Local Storage fallback solutions for more info on those options.

Upvotes: 4

Related Questions