且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用JavaScript或jQuery刷新父页面后保留iframe src?

更新时间:2022-12-07 08:38:02

有几种方法临时存储iframe的 URL ,然后检索它会在下一页重新加载。

  1. 将其存储为cookie

  2. 使用 localStorage

  3. 使用 window.name - er,no。哈。开玩笑。这是一个很糟糕的破解。

  4. 使用管理localStorage的小包之一,如果必须的话,默认返回到cookie。 >

    您可能需要阅读 HTML5本地存储回退解决方案了解更多有关这些选项的信息。


    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?

    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.