iFrames 创建模板
您好,我想创建一个具有以下结构的网站:
这个想法是在左帧和右帧中的左图像和边框图像。标题将包含页面标题以及用户信息(即登录、注销按钮等)。内容区域是显示站点内容的区域。我只想在按下左框架菜单中的按钮时更新此内容...
如何使用 iframe 实现此目的?抱歉,我是 HTML 菜鸟...框架是最好的方法吗?我只想更新页面的一部分,而不是每次重新绘制整个页面。
Hi I want to create a website which has the following structure:
The idea is to have a menu in the left and border images in the left and right frames. the header will contain the page title and also user information (i.e. logged in, log out button etc). The content region is the one where the site content is displayed. I want to only update this as buttons are pressed in the menu in the left frame...
How can I achieve this using iframes? Sorry I am a HTML noob.... Are frames the best approach? I just want to have a part of the page that updates as opposed to the entire page redrawing each time..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上框架并不是一个好的方法。如果可能的话,您应该避免使用框架并完全忘记它们的存在。 框架是邪恶的。
更好的方法是使用预处理器(PHP、ASP、Python,..)将页面的部分内容包含到 HTML 中。有许多框架和模板系统可以为您完成艰苦的工作。例如,对于 PHP,请参阅 Smarty 模板引擎。
如果您不希望浏览器重新加载所有页面,而仅重新加载页面中间的内容 AJAX 是更好的解决方案。
更新:
在 jQuery 中,您可以使用 jQuery.click() 和 jQuery.load() 函数用于在用户单击菜单项时加载新内容并将其放置到页面中。
使用 ajax 动态加载新内容的最佳实践是为禁用 JavaScript 的机器(例如搜索引擎爬虫)提供替代方案。然而,从头开始正确实现这一点有点复杂,但是有一些框架可以帮助您。就我个人而言,我更喜欢 Nette Framework,因为与其他框架相比,它轻量级且高效。
Actually frames are NOT a good approach. You should avoid frames and completely forget about their existence if possible. Frames are evil.
Better approach is use of a preprocessor (PHP, ASP, Python,..) to include parts of the page into HTML. There are many frameworks and templating systems which will do the hard work for you. E.g. for PHP see Smarty temlating engine.
If you don't want browsers to reload all page but only content in the middle of the page AJAX is much better solution.
Update:
In jQuery you could use jQuery.click() and jQuery.load() functions to load and place new content into page when a user clicks on a menu item.
Best practice when using ajax to load new content dynamically is to provide also alternative for machines with disabled JavaScript (e.g. search engines crawlers). However it's bit more complicated to implement this properly from a scratch, but there are some frameworks which can help you. Personally I prefer Nette Framework because it's lightweight and efficient in comparison to other frameworks.