Include the content from other webpages: Difference between revisions
Jump to navigation
Jump to search
(→usage) |
|||
| Line 1: | Line 1: | ||
Multiple approaches for including the content from other webpages | Multiple approaches for including the content from other webpages | ||
= | = Usage = | ||
# seperate the navigation and content into two parts | # seperate the navigation and content into two parts | ||
# compare the content from two webpages | # compare the content from two webpages | ||
== Comparison of iframe and ajax == | |||
# Load data<ref>[https://stackoverflow.com/questions/382662/what-are-the-differences-between-using-an-iframe-and-ajax-to-include-the-content What are the differences between using an iframe and ajax to include the contents of an external page? - Stack Overflow]</ref> | |||
#* iframe: available | |||
#* ajax: available | |||
# CSS rules were infected from original page called | |||
#* iframe: No | |||
#* ajax: Yes, Need to consider the CSS issue {{exclaim}} | |||
# Callback actions called after loaded the content | |||
#* iframe: Available<ref>[https://stackoverflow.com/questions/164085/javascript-callback-when-iframe-is-finished-loading events - Javascript callback when IFRAME is finished loading? - Stack Overflow]</ref> ''not verified'' | |||
#* ajax: Available<ref>[http://api.jquery.com/jquery.ajax/ jQuery.ajax() | jQuery API Documentation]</ref> | |||
= client-side approach = | = client-side approach = | ||
Revision as of 15:01, 12 September 2017
Multiple approaches for including the content from other webpages
Usage
- seperate the navigation and content into two parts
- compare the content from two webpages
Comparison of iframe and ajax
- Load data[1]
- iframe: available
- ajax: available
- CSS rules were infected from original page called
- iframe: No
- ajax: Yes, Need to consider the CSS issue

- Callback actions called after loaded the content
client-side approach
Frame or iframe
- frame or iframe tag, object tag
- 缺點是瀏覽器上的鏈結,非該篇網頁的靜態鏈結。
- 額外需要處理的議題:(1)點選連結,內容會直接顯示在 frame 內,如果 frame 太小,會需要額外處理。例如:frame內的連結,以新視窗開啟。(2)Iframes and CSS - Styling Iframes With CSS
- cross frame layers
Javascript
- general (JavaScript Tip: Page Headers And Footers)
<script language="JavaScript" type="text/javascript" src="path/to.js"></script> <noscript><a href="URL">Description</a><noscript>
jQuery .load() or jQuery.ajax()
- the code of "Click event" should written in the loaded file.
Server-side approach
Apache
CMS software or Wiki softwares
CMS softwares
- Decoupled CMS: Why “Going Headless” Is Becoming So Popular | Pantheon [Last visited: 2017-09-12]
Wiki softwares
- DokuWiki: DokuWiki export or use the plugin plugin:getraw
- Mediawiki:
- MediaWiki Template or transclude syntax(Mediawiki formatting rules)
- Include the content of wiki page from other software API:FAQ - MediaWiki ex: https://meta.wikimedia.org/w/index.php?title=Spam_blacklist&action=raw&sb_ver=1 [Last visited: 2016-02-16]
- Oddmuse wiki: Transclusion means to include a wiki page from elsewhere into your current page
Other softwares
- MovableType: template modules, or MultiBlog plugin
PHP require / include function
PHP require_once(), include function ...
troubleshooting:
- (When I browsed some_file.php which include )Warning: include_once(lib.php) [function.include-once]: failed to open stream: No such file or directory in ...common/view.php
common/lib.php common/view.php //the file included common/lib.php some_file.php //the file included common/view.php
- solution:
- Using CONSTANT parameter (such as absolute file path in common configuration file) in the included path NOT using relative path
- Resolving PHP Relative Paths Problems - Ant's ATField
further reading
- Boutell.Com, Inc. (2007). How Do I Include One HTML File in Another? / Jennifer Kyrnin (n.d.). [2]
- How to include an html page into an html page