将.asp文件包含到html文件中

时间:2022-04-22 05:38:43

How can include .asp file inside of html file and have it proccessed besides having to process all html files with asp.

如何在html文件中包含.asp文件,除了必须用asp处理所有html文件之外,还要使用它。

5 个解决方案

#1


you could use an IFRAME tag...but it's a bit sucky. I'd do what Phantom Watson says.

你可以使用IFRAME标签......但它有点太糟糕了。我会做Phantom Watson所说的。

#2


I'm not totally sure what you're asking. If you're attempting to include a .asp file into a .html file, I don't believe it's possible. If you change your file's extension to .shtml, then you can put the following line into the HTML file:

我不完全确定你在问什么。如果您尝试将.asp文件包含到.html文件中,我认为不可能。如果将文件扩展名更改为.shtml,则可以将以下行放入HTML文件中:

<!--#include virtual="path to asp file/include-file.asp" -->

Now, whether or not the ASP would be parsed or the code will be displayed will have to be addressed by someone that understands server parsing better than me.

现在,无论是否将解析ASP或将显示代码,都必须由了解服务器解析比我更好的人来解决。

What would be a better solution is to just include an ASP file into another ASP file. If you want functionality like page-including, then giving your files .html or .shtml extensions will only make it harder to accomplish what you're trying.

更好的解决方案是将ASP文件包含在另一个ASP文件中。如果你想要包含页面的功能,那么提供你的文件.html或.shtml扩展只会让你更难完成你正在尝试的东西。

Basically, use .asp for files that you want parsed and .html for files that can be served up to the user as-is.

基本上,对于要解析的文件使用.asp,对于可以按原样提供给用户的文件使用.html。

#3


You can change executable extensions, so, if you want, you can make .html executable so that you could include file or do anything else.. Go to IIS manager (run->inetmgr), choose properties of your site, under tab 'Home directory' press 'Configuration..' You can add an extension there and an executable (you can insert the same as in the .asp)

您可以更改可执行扩展,因此,如果需要,您可以制作.html可执行文件,以便您可以包含文件或执行任何其他操作。转到IIS管理器(运行 - > inetmgr),选择站点的属性,在选项卡'下主目录'按'配置..'你可以在那里添加一个扩展和一个可执行文件(你可以插入与.asp相同的内容)

But I don't think this is a best choise :) if it's exetutable, it should be .asp, if it's not - html

但我不认为这是最好的选择:)如果它是exetutable,它应该是.asp,如果它不是 - html

#4


One of the possible solutions is to change the extension of your page from .html to .asp as it will have no effect on your page and its execution.Then you can include the .asp file normally as we include it in .asp files.

其中一种可能的解决方案是将页面的扩展名从.html更改为.asp,因为它对您的页面及其执行没有任何影响。然后,您可以正常包含.asp文件,因为我们将其包含在.asp文件中。

#5


I know this is a old question but for those interested, there is a solution to it if you code it right, i figured out how to with some testing I did. I got a working coded version of it so I know for a fact it works but i'll try to explain it out.

我知道这是一个老问题但是对于那些感兴趣的人,如果你正确编码它有一个解决方案,我想出了如何进行一些测试。我有一个工作的编码版本,所以我知道它的工作原理,但我会尝试解释它。

Lets say you have a header, navbar or footer (the usual place of a copyright year/info that Boris mentioned in one of his comments). Yet you don't want to change the .html / .htm file extension of however so many of those files because of the links involved and if other sites link to your website.

假设你有一个标题,导航栏或页脚(Boris在他的一条评论中提到的版权年/信息的通常位置)。然而,由于涉及的链接以及其他网站链接到您的网站,您不希望更改这些文件的.html / .htm文件扩展名。

Though for Boris its just the footer of each file, easy way to do that is by putting the following in your html files where ever your footer code is placed.

虽然对于Boris来说它只是每个文件的页脚,但是简单的方法是将以下内容放在你的页脚代码所在的html文件中。

<script type="text/javascript" src="Footer.asp"></script>

That was the first part of it, the next part is using JavaScript within the footer ASP file like so:

这是它的第一部分,下一部分是在页脚ASP文件中使用JavaScript,如下所示:

var Code ='';
Code+='your html here';
Code+='more html here if needed';
document.write(Code);

You can even put functions above the var and those functions will work with whatever you have in the: Code+='your html here'; Now in that bit of code you might have for example something like: Code+='<form id="UserSignUp" name="UserSignUp" method="post" action="AddUser.asp">'; and you can say for example add users to a database.

您甚至可以将函数放在var之上,这些函数将适用于您的所有内容:Code + ='your html here';现在,您可以使用以下代码:Code + ='

';你可以说例如将用户添加到数据库。

But in Boris case it's the copyright year, so in that same Footer.asp file you have a few options. In the Code+='your html here'; you can use the code you made / found that updates it year by year or you can manually update it once per year on just that one file.

但在Boris案例中它是版权年份,所以在同一个Footer.asp文件中你有几个选项。在Code + ='你的html here';您可以使用您创建/找到的代码逐年更新它,或者您可以每年仅在该文件上手动更新一次。

Yet it begs the question of, why are you not using JavaScript in the first place for the copyright year with the document.write(); in a Footer.js file instead. Unless your copyright year code is in ASP?

然而,它引出了一个问题,为什么你没有在document.write()的版权年度首先使用JavaScript?而是在Footer.js文件中。除非您的版权年代码在ASP中?

In which case in that Footer.asp file above the JavaScript functions, just add your ASP code such as for example: rsYear("CopyrightYear") = Now along with the rest of the ASP code that you might need.

在JavaScript函数上方的Footer.asp文件中,只需添加您的ASP代码,例如:rsYear(“CopyrightYear”)= Now以及您可能需要的其余ASP代码。

While in the JavaScript add something along the lines of:

在JavaScript中添加以下内容:

Code+='<script>document.write("Copyright: <%=rsYear("CopyrightYear")%>");</script>';

#1


you could use an IFRAME tag...but it's a bit sucky. I'd do what Phantom Watson says.

你可以使用IFRAME标签......但它有点太糟糕了。我会做Phantom Watson所说的。

#2


I'm not totally sure what you're asking. If you're attempting to include a .asp file into a .html file, I don't believe it's possible. If you change your file's extension to .shtml, then you can put the following line into the HTML file:

我不完全确定你在问什么。如果您尝试将.asp文件包含到.html文件中,我认为不可能。如果将文件扩展名更改为.shtml,则可以将以下行放入HTML文件中:

<!--#include virtual="path to asp file/include-file.asp" -->

Now, whether or not the ASP would be parsed or the code will be displayed will have to be addressed by someone that understands server parsing better than me.

现在,无论是否将解析ASP或将显示代码,都必须由了解服务器解析比我更好的人来解决。

What would be a better solution is to just include an ASP file into another ASP file. If you want functionality like page-including, then giving your files .html or .shtml extensions will only make it harder to accomplish what you're trying.

更好的解决方案是将ASP文件包含在另一个ASP文件中。如果你想要包含页面的功能,那么提供你的文件.html或.shtml扩展只会让你更难完成你正在尝试的东西。

Basically, use .asp for files that you want parsed and .html for files that can be served up to the user as-is.

基本上,对于要解析的文件使用.asp,对于可以按原样提供给用户的文件使用.html。

#3


You can change executable extensions, so, if you want, you can make .html executable so that you could include file or do anything else.. Go to IIS manager (run->inetmgr), choose properties of your site, under tab 'Home directory' press 'Configuration..' You can add an extension there and an executable (you can insert the same as in the .asp)

您可以更改可执行扩展,因此,如果需要,您可以制作.html可执行文件,以便您可以包含文件或执行任何其他操作。转到IIS管理器(运行 - > inetmgr),选择站点的属性,在选项卡'下主目录'按'配置..'你可以在那里添加一个扩展和一个可执行文件(你可以插入与.asp相同的内容)

But I don't think this is a best choise :) if it's exetutable, it should be .asp, if it's not - html

但我不认为这是最好的选择:)如果它是exetutable,它应该是.asp,如果它不是 - html

#4


One of the possible solutions is to change the extension of your page from .html to .asp as it will have no effect on your page and its execution.Then you can include the .asp file normally as we include it in .asp files.

其中一种可能的解决方案是将页面的扩展名从.html更改为.asp,因为它对您的页面及其执行没有任何影响。然后,您可以正常包含.asp文件,因为我们将其包含在.asp文件中。

#5


I know this is a old question but for those interested, there is a solution to it if you code it right, i figured out how to with some testing I did. I got a working coded version of it so I know for a fact it works but i'll try to explain it out.

我知道这是一个老问题但是对于那些感兴趣的人,如果你正确编码它有一个解决方案,我想出了如何进行一些测试。我有一个工作的编码版本,所以我知道它的工作原理,但我会尝试解释它。

Lets say you have a header, navbar or footer (the usual place of a copyright year/info that Boris mentioned in one of his comments). Yet you don't want to change the .html / .htm file extension of however so many of those files because of the links involved and if other sites link to your website.

假设你有一个标题,导航栏或页脚(Boris在他的一条评论中提到的版权年/信息的通常位置)。然而,由于涉及的链接以及其他网站链接到您的网站,您不希望更改这些文件的.html / .htm文件扩展名。

Though for Boris its just the footer of each file, easy way to do that is by putting the following in your html files where ever your footer code is placed.

虽然对于Boris来说它只是每个文件的页脚,但是简单的方法是将以下内容放在你的页脚代码所在的html文件中。

<script type="text/javascript" src="Footer.asp"></script>

That was the first part of it, the next part is using JavaScript within the footer ASP file like so:

这是它的第一部分,下一部分是在页脚ASP文件中使用JavaScript,如下所示:

var Code ='';
Code+='your html here';
Code+='more html here if needed';
document.write(Code);

You can even put functions above the var and those functions will work with whatever you have in the: Code+='your html here'; Now in that bit of code you might have for example something like: Code+='<form id="UserSignUp" name="UserSignUp" method="post" action="AddUser.asp">'; and you can say for example add users to a database.

您甚至可以将函数放在var之上,这些函数将适用于您的所有内容:Code + ='your html here';现在,您可以使用以下代码:Code + ='

';你可以说例如将用户添加到数据库。

But in Boris case it's the copyright year, so in that same Footer.asp file you have a few options. In the Code+='your html here'; you can use the code you made / found that updates it year by year or you can manually update it once per year on just that one file.

但在Boris案例中它是版权年份,所以在同一个Footer.asp文件中你有几个选项。在Code + ='你的html here';您可以使用您创建/找到的代码逐年更新它,或者您可以每年仅在该文件上手动更新一次。

Yet it begs the question of, why are you not using JavaScript in the first place for the copyright year with the document.write(); in a Footer.js file instead. Unless your copyright year code is in ASP?

然而,它引出了一个问题,为什么你没有在document.write()的版权年度首先使用JavaScript?而是在Footer.js文件中。除非您的版权年代码在ASP中?

In which case in that Footer.asp file above the JavaScript functions, just add your ASP code such as for example: rsYear("CopyrightYear") = Now along with the rest of the ASP code that you might need.

在JavaScript函数上方的Footer.asp文件中,只需添加您的ASP代码,例如:rsYear(“CopyrightYear”)= Now以及您可能需要的其余ASP代码。

While in the JavaScript add something along the lines of:

在JavaScript中添加以下内容:

Code+='<script>document.write("Copyright: <%=rsYear("CopyrightYear")%>");</script>';