#includde<myheadfile.h>和#include"myheadflie.h"的不

Use VLC to Play Videos Inside an RAR FileI have 2 HTML files, suppose a.html and b.html. In a.html I want to include b.html.
In JSF I can do it like that:
&ui:include src="b.xhtml" /&
It means that inside a.xhtml file, I can include b.xhtml.
How can we do it in *.html file?
595k15219822282
4,72651229
In my opinion the best solution is:
Using jQuery:
&script src="jquery.js"&&/script&
$(function(){
$("#includedContent").load("b.html");
&div id="includedContent"&&/div&
&p& This is my include file &/p&
Like that i can get a simple and clean solution to my problem.
4,72651229
My solution is similar to the one of
above. However, I insert the HTML code via JavaScript's document.write instead of using jQuery:
&h1&Put here your HTML content before insertion of b.js.&/h1&
&script src="b.js"&&/script&
&p&And here whatever content you want afterwards.&/p&
document.write('\
&h1&Add your HTML code here&/h1&\
&p&Notice however, that you have to escape LF's with a '\', just like\
demonstrated in this code listing.\
The reason for me against using jQuery is that jQuery.js is ~90kb in size, and I want to keep the amount of data to load as small as possible.
In order to insert the escape characters without much work, I recommend using a simple regular expression that matches whole lines (^.*$) and adds \ at the end of each line. For example, you could use sed on the command line like this:
sed 's/^.*$/&\\/g;' b.html & escapedB.html
2,68821628
A simple server side include directive to include another file found in the same folder looks like this:
&!--#include virtual="a.html" --&
Checkout HTML5 imports
For example:
&link rel="import" href="/path/to/imports/stuff.html"&
*You can enable the flag by turning on Enable experimental Web Platform features in about:flags in Chrome Canary.
5,41953577
I did met my needs back then, but here's how to do it standards-compliant code:
&!--[if IE]&
&object classid="clsid:F9-11CF-8FD0-00AA00686F13" data="some.html"&
&p&backup content&/p&
&![endif]--&
&!--[if !IE]& &--&
&object type="text/html" data="some.html"&
&p&backup content&/p&
&!--& &![endif]--&
5,29492249
Shameless plug of a library that I wrote the solve this.
&div data-include="/path/to/include.html"&&/div&
The above will take the contents of /path/to/include.html and replace the div with it.
As an alternative, if you have access to the .htaccess file on your server, you can add a simple directive that will allow php to be interpreted on files ending in .html extension.
RemoveHandler .html
AddType application/x-httpd-php .php .html
Now you can use a simple php script to include other files such as:
&?php include('b.html'); ?&
No need for scripts. No need to do any fancy stuff server-side (tho that would probably be a better option)
&iframe src="/path/to/file.html" seamless&&/iframe&
Since old browsers don't support seamless, you should add some css to fix it:
iframe[seamless] {
Keep in mind that for browsers that don't support seamless, if you click a link in the iframe it will make the frame go to that url, not the whole window. A way to get around that is to have all links have target="_parent", tho the browser support is "good enough".
To insert contents of the named file:
&!--#include virtual="filename.htm"--&
51.2k1671106
The Athari?s answer (the first!) was too much conclusive! Very Good!
But if you would like to pass the name of the page to be included as URL parameter, this post has a very nice solution to be used combined with:
So it becomes something like this:
/a.html?p=b.html
The a.html code now becomes:
&script src="jquery.js"&&/script&
function GetURLParameter(sParam)
var sPageURL = window.location.search.substring(1);
var sURLVariables = sPageURL.split('&');
for (var i = 0; i & sURLVariables. i++)
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == sParam)
return sParameterName[1];
$(function(){
var pinc = GetURLParameter('p');
$("#includedContent").load(pinc);
&div id="includedContent"&&/div&
It worked very well for me!
I hope have helped :)
Most of the solutions works but they have issue with jquery:
The issue is following code $(document).ready(function () { alert($("#includedContent").text()); } alerts nothing instead of alerting included content.
I write the below code, in my solution you can access to included content in $(document).ready function:
(The key is loading included content synchronously).
index.htm:
&script src="jquery.js"&&/script&
(function ($) {
$.include = function (url) {
async: false,
success: function (result) {
document.write(result);
}(jQuery));
$(document).ready(function () {
alert($("#test").text());
&script&$.include("include.inc");&/script&
include.inc:
&div id="test"&
There is no issue between this solution and jquery.
3,04153777
Following works if html content from some file needs to be included:
For instance, the following line will include the contents of piece_to_include.html at the location where the OBJECT definition occurs.
...text before...
&OBJECT data="file_to_include.html"&
Warning: file_to_include.html could not be included.
...text after...
Reference:
Expanding lolo's answer from above, here is a little more automatisation if you have to include a lot of files:
$(function(){
var includes = $('.include');
jQuery.each(includes, function(){
var file = 'views/' + $(this).data('include') + '.html';
$(this).load(file);
And then to include something in the html:
&div class="include" data-include="header"&&/div&
&div class="include" data-include="footer"&&/div&
Which would include the file views/header.html and views/footer.html
I came to this topic looking for something similar, but a bit different from the problem posed by lolo.
I wanted to construct an HTML page holding an alphabetical menu of links to other pages, and each of the other pages might or might not exist, and the order in which they were created might not be alphabetical (nor even numerical).
Also, like Tafkadasoh, I did not want to bloat the web page with jQuery.
After researching the problem and experimenting for several hours, here is what worked for me, with relevant remarks added:
&!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&
&meta http-equiv="Content-Type" content="text/application/ charset=iso-8859-1"&
&meta name="Author" content="me"&
&meta copyright="Copyright" content= "(C) 2013-present by me" /&
&title&Menu&/title&
&script type="text/javascript"&
var F000, F001, F002, F003, F004, F005, F006, F007, F008, F009,
F010, F011, F012, F013, F014, F015, F016, F017, F018, F019;
var dat = new Array();
var form, script, write, str, tmp, dtno, indx,
The "F000" and similar variables need to exist/be-declared.
Each one will be associated with a different menu item,
so decide on how many items maximum you are likely to need,
when constructing that listing of them.
Here, there are 20.
function initialize()
{ window.name="Menu";
form = document.getElementById('MENU');
for(indx=0; indx&20; indx++)
{ str = "00" +
tmp = str.length - 3;
str = str.substr(tmp);
script = document.createElement('script');
script.type = 'text/javascript';
script.src = str + ".js";
form.appendChild(script);
The for() loop constructs some &script& objects
and associates each one with a different simple file name,
starting with "000.js" and, here, going up to "019.js".
It won't matter which of those files exist or not.
However, for each menu item you want to display on this
page, you will need to ensure that its .js file does exist.
The short function below (inside HTML comment-block) is,
generically, what the content of each one of the .js files looks like:
function F000()
{ return ["Menu Item Name", "./URLofFile.htm", "Description string"];
(Continuing the remarks in the main menu.htm file)
It happens that each call of the form.appendChild() function
will cause the specified .js script-file to be loaded at that time.
However, it takes a bit of time for the JavaScript in the file
to be fully integrated into the web page, so one thing that I tried,
but it didn't work, was to write an "onload" event handler.
The handler was apparently being called before the just-loaded
JavaScript had actually become accessible.
Note that the name of the function in the .js file is the same as one
of the the pre-defined variables like "F000".
When I tried to access
that function without declaring the variable, attempting to use an
"onload" event handler, the JavaScript debugger claimed that the item
was "not available".
This is not something that can be tested-for!
However, "undefined" IS something that CAN be tested-for.
declaring them to exist automatically makes all of them "undefined".
When the system finishes integrating a just-loaded .js script file,
the appropriate variable, like "F000", will become something other
than "undefined".
Thus it doesn't matter which .js files exist or
not, because we can simply test all the "F000"-type variables, and
ignore the ones that are "undefined".
More on that later.
The line below specifies a delay of 2 seconds, before any attempt
is made to access the scripts that were loaded.
That DOES give the
system enough time to fully integrate them into the web page.
(If you have a really long list of menu items, or expect the page
to be loaded by an old/slow computer, a longer delay may be needed.)
window.setTimeout("BuildMenu();", 2000);
//So here is the function that gets called after the 2-second delay
function BuildMenu()
{ dtno = 0;
//index-counter for the "dat" array
for(indx=0; indx&20; indx++)
{ str = "00" +
tmp = str.length - 3;
str = "F" + str.substr(tmp);
tmp = eval(str);
if(tmp != unde) // "unde" is deliberately undefined, for this test
dat[dtno++] = eval(str + "()");
The loop above simply tests each one of the "F000"-type variables, to
see if it is "undefined" or not.
Any actually-defined variable holds
a short function (from the ".js" script-file as previously indicated).
We call the function to get some data for one menu item, and put that
data into an array named "dat".
Below, the array is sorted alphabetically (the default), and the
"dtno" variable lets us know exactly how many menu items we will
be working with.
The loop that follows creates some "&span&" tags,
and the the "innerHTML" property of each one is set to become an
"anchor" or "&a&" tag, for a link to some other web page.
A description
and a "&br /&" tag gets included for each link.
Finally, each new
&span& object is appended to the menu-page's "form" object, and thereby
ends up being inserted into the middle of the overall text on the page.
(For finer control of where you want to put text in a page, consider
placing something like this in the web page at an appropriate place,
as preparation:
&div id="InsertHere"&&/div&
You could then use document.getElementById("InsertHere") to get it into
a variable, for appending of &span& elements, the way a variable named
"form" was used in this example menu page.
Note: You don't have to specify the link in the same way I did
(the type of link specified here only works if JavaScript is enabled).
You are free to use the more-standard "&a&" tag with the "href"
property defined, if you wish.
But whichever way you go,
you need to make sure that any pages being linked actually exist!
dat.sort();
for(indx=0; indx& indx++)
{ write = document.createElement('span');
write.innerHTML = "&a onclick=\"window.open('" + dat[indx][1] +
"', 'Menu');\" style=\"color:#0000" +
"text-decoration:cursor:\"&" +
dat[indx][0] + "&/a& " + dat[indx][2] + "&br /&";
form.appendChild(write);
&body onload="initialize();" style="background-color:#a0a0a0; color:#000000;
font-family:sans- font-size:11"&
&h2&& & & & & & &
& & & & & &MENU
&noscript&&br /&&span style="color:#ff0000;"&
Links here only work if&br /&
your browser's JavaScript&br /&
support is enabled.&/span&&br /&&/noscript&&/h2&
These are the menu items you currently have available:&br /&
&form id="MENU" action="" onsubmit=""&
&!-- Yes, the &form& object starts out completely empty --&
Click any link, and enjoy it as much as you like.&br /&
Then use your browser's BACK button to return to this Menu,&br /&
so you can click a different link for a different thing.&br /&
&small&This file (web page) Copyright (c) 2013-present by me&/small&
If you use some framework like django/bootle, they often ship some template engine.
Let's say you use bottle, and the default template engine is .
And below is the pure html file
$ cat footer.tpl
&hr& &footer&
&p&& stackoverflow, inc 2015&/p& &/footer&
You can include the footer.tpl in you main file, like:
$ cat dashboard.tpl
%include footer
Besides that, you can also pass parameter to your dashborard.tpl.
There is no direct HTML solution for the task for now. Even
(which is permanently in
draft) will not do the thing, because Import != Include and some JS magic will be required anyway.
I recently wrote
that is just for inclusion HTML into HTML, without any complications.
Just place in your a.html
&link data-wi-src="b.html" /&
&!-- ... and somewhere below is ref to the script ... --&
&script src="wm-html-include.js"& &/script&
It is open-source and may give an idea (I hope)
, You can implement common library and just use below code to import any HTML files in one line.
&link rel="import" href="warnings.html"&
You can also try
3,07612227
Well, if all you're wanting to do is put text from a separate file into your page (tags in the text should work, too), you can do this (your text styles on the main page—test.html—should still work):
&p&Start&/p&
&p&Beginning&/p&
&script language="JavaScript" src="sample.js"&&/script&
&p&End&/p&
var data="Here is the imported text!";
document.write(data);
You can always recreate the HTML tags you want yourself, after all. There's need for server-side scripting just to grab text from another file, unless you want to do something more.
Anyway, what I'm starting to use this for is to make it so if I update a description common among lots of HTML files, I only need to update one file to do it (the .js file) instead of every single HTML file that contains the text.
So, in summary, instead of importing an .html file, a simpler solution is to import a .js file with the content of the .html file in a variable (and write the contents to the screen where you call the script).
Thanks for the question.
PHP is a server level scripting language. It can do many things, but one popular use is to include HTML documents inside your pages, much the same as SSI. Like SSI, this is a server level technology. If you are not sure if you have PHP functionality on your website contact your hosting provider.
Here is a simple PHP script you can use to include a snippet of HTML on any PHP-enabled web page:
Save the HTML for the common elements of your site to separate files. For example, your navigation section might be saved as navigation.html or navigation.php.
Use the following PHP code to include that HTML in each page.
&?php require($DOCUMENT_ROOT . "navigation.php"); ?&
Use that same code on every page that you want to include the file.
Make sure to change the higlighted file name to the name and path to your include file.
6,51852255
using jquery u need import library
i recommend you using php
echo"&html&
include "b.html";
echo" &/body&
&div&hi this is ur file :3&div&
protected by
Thank you for your interest in this question.
Because it has attracted low-quality answers, posting an answer now requires 10
on this site.
Would you like to answer one of these
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabledGetFullPathName function (Windows)
Expand the table of content
GetFullPathName function
Retrieves the full path and file name of the specified file.
To perform this operation as a transacted operation, use the
For more information about file and path names, see
The GetFullPathName function is not recommended for
multithreaded applications or shared library code. For more information, see the Remarks section.
DWORD WINAPI GetFullPathName(
LPCTSTR lpFileName,
nBufferLength,
_Out_ LPTSTR
_Out_ LPTSTR
*lpFilePart
Parameters
lpFileName [in]
The name of the
This parameter can be a short (the 8.3 form) or long file name. This string can also be a share or volume
In the ANSI version of this function, the name is limited to MAX_PATH characters.
To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend
"\\?\" to the path. For more information, see
nBufferLength [in]
The size of the buffer to receive the null-terminated string for the drive and path, in
lpBuffer [out]
A pointer to a buffer that receives the null-terminated string for the
drive and path.
lpFilePart [out]
A pointer to a buffer that receives the address (within lpBuffer) of the final
file name component in the path.
This parameter can be
If lpBuffer
refers to a directory and not a file, lpFilePart receives zero.
Return value
If the function succeeds, the return value is the length, in TCHARs, of the
string copied to lpBuffer, not including the terminating null character.
If the lpBuffer buffer is too small to contain the path, the return value is the
size, in TCHARs, of the buffer that is required to hold the path and the
terminating null character.
If the function fails for any other reason, the return value is zero. To get extended error information, call
GetFullPathName merges the name of the current drive
and directory with a specified file name to determine the full path and file name of a specified file. It also
calculates the address of the file name portion of the full path and file name.
This function does not verify that the resulting path and file name are valid, or that they see an existing
file on the associated volume.
Note that the lpFilePart parameter does not
require string buffer space, but only enough for a single address. This is because it simply returns an address
within the buffer that already exists for lpBuffer.
Share and volume names are
valid input for lpFileName. For example, the following list identities the returned path
and file names if test-2 is a remote computer and U: is a network mapped drive:
If you specify "\\test-2\q$\lh" the path returned is
"\\test-2\q$\lh"
If you specify "\\?\UNC\test-2\q$\lh" the path returned is
"\\?\UNC\test-2\q$\lh"
If you specify "U:" the path returned is
GetFullPathName does not convert the specified file
name, lpFileName. If the specified file name exists, you can use
to convert to long or short path
names, respectively.
If the return value is greater than or equal to the value specified in
nBufferLength, you can call the function again with a buffer that is large enough to
hold the path. For an example of this case in addition to using zero-length buffer for dynamic allocation, see the
Example Code section.
Although the return value in this case is a length that includes the terminating null character, the return
value on success does not include the terminating null character in the count.
Multithreaded applications and shared library code should not use the
GetFullPathName function and should avoid using relative
path names. The current directory state written by the
function is stored as a global
variable in each process, therefore multithreaded applications cannot reliably use this value without possible
data corruption from other threads that may also be reading or setting this value. This limitation also applies
to the SetCurrentDirectory and
functions. The exception being
when the application is guaranteed to be running in a single thread, for example parsing file names from the
command line argument string in the main thread prior to creating any additional threads. Using relative path
names in multithreaded applications or shared library code can yield unpredictable results and is not
supported.
In Windows 8 and Windows Server 2012, this function is supported by the following technologies.
TechnologySupported
Server Message Block (SMB) 3.0 protocol
SMB 3.0 Transparent Failover (TFO)
SMB 3.0 with Scale-out File Shares (SO)
Cluster Shared Volume File System (CsvFS)
Resilient File System (ReFS)
The following C++ example shows a basic use of
GetFullPathName,
. For another example using dynamic
allocation, see .
#include &windows.h&
#include &tchar.h&
#include &stdio.h&
#define BUFSIZE 4096
#define LONG_DIR_NAME TEXT("c:\\longdirectoryname")
void _tmain(int argc, TCHAR *argv[])
buffer[BUFSIZE]=TEXT("");
buf[BUFSIZE]=TEXT("");
TCHAR** lppPart={NULL};
if( argc != 2 )
_tprintf(TEXT("Usage: %s [file]\n"), argv[0]);
// Retrieve the full path name for a file.
// The file does not need to exist.
retval = GetFullPathName(argv[1],
if (retval == 0)
// Handle an error condition.
printf ("GetFullPathName failed (%d)\n", GetLastError());
_tprintf(TEXT("The full path name is:
%s\n"), buffer);
if (lppPart != NULL && *lppPart != 0)
_tprintf(TEXT("The final component in the path name is:
%s\n"), *lppPart);
// Create a long directory name for use with the next two examples.
success = CreateDirectory(LONG_DIR_NAME,
if (!success)
// Handle an error condition.
printf ("CreateDirectory failed (%d)\n", GetLastError());
// Retrieve the short path name.
retval = GetShortPathName(LONG_DIR_NAME,
if (retval == 0)
// Handle an error condition.
printf ("GetShortPathName failed (%d)\n", GetLastError());
else _tprintf(TEXT("The short name for %s is %s\n"),
LONG_DIR_NAME, buf);
// Retrieve the long path name.
retval = GetLongPathName(buf,
if (retval == 0)
// Handle an error condition.
printf ("GetLongPathName failed (%d)\n", GetLastError());
else _tprintf(TEXT("The long name for %s is %s\n"), buf, buffer);
// Clean up the directory.
success = RemoveDirectory(LONG_DIR_NAME);
if (!success)
// Handle an error condition.
printf ("RemoveDirectory failed (%d)\n", GetLastError());
Requirements
Minimum supported client
Windows XP [desktop apps only]
Minimum supported server
Windows Server 2003 [desktop apps only]
FileAPI.h (include Windows.h);
WinBase.h on Windows Server 2008 R2, Windows 7, Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP (include Windows.h)
Kernel32.lib
Kernel32.dll
Unicode and ANSI names
GetFullPathNameW (Unicode) and GetFullPathNameA (ANSI)
Was this page helpful?
Your feedback about this content is important.Let us know what you think.
Additional feedback?
1500 characters remaining
Thank you!
We appreciate your feedback.
Related developer sites
Downloads and tools
Essentials

我要回帖

更多关于 lt gt eq 的文章

 

随机推荐