开发者

Looking for advice using jQuery to load content into DIVs for new web site instead of IFrame

开发者 https://www.devze.com 2023-03-26 15:27 出处:网络
I\'m a long time ASP.NET/AJAX developer so working with jQuery is a big change for me. I\'m looking to have a single HTML page with a single header and a left side navigation.The left side navigation

I'm a long time ASP.NET/AJAX developer so working with jQuery is a big change for me.

I'm looking to have a single HTML page with a single header and a left side navigation. The left side navigation is a jQuery/UI accordion with menu options. When a link is selected from the nav, I want another external page to be displayed on the current page without navigating away from the page. I'm guessing this is the correct approach because I don't want to define the header and navigation for each page. I could use a master page in my .NET pages.

My first inclination was to use an IFrame on my page. 开发者_运维百科Most of the information I've found on this topic is to try and avoid using IFrames all together. I'm looking for the best technique; what is generally the best/correct way to do this. So I replaced the IFrame with a and use $("#xxx").content("filename"); to load my content and it appears to work. But is this approach flawed?

Does this generally work? Is this a correct approach? Is there something better? I'm looking for anything that can help me understand the correct way to do this.

Any tips, links, recommended books on the subject, are greatly appreciated.

Thank you so much.


The approach is correct. Everyone is against iframes, but this approach is not giving you anything better or worse, except being trendy.

With iframes you gain the back of the browser working.

With both approaches you loose bookmarks. I cannot bookmark the entire state of your page, so i cannot bookmark (or copy and paste to a friend) an internal page of your site.

A way to solve the bookmark problem is to use the hash part of the url. Changing that part of the url does not cause a page reload, but it retained in the bookmark and displayed. You could put the file name there, and on page load read if the is something (meaning they arrived using a bookmark) and load the proper page.

There is a nice jquery plugin to deal with hash urls : http://benalman.com/projects/jquery-hashchange-plugin/

0

精彩评论

暂无评论...
验证码 换一张
取 消