简体   繁体   English

是否可以在Visual Studio C ++项目中将Javascript和CSS代码与HTML代码分开?

[英]Is it posible to separate Javascript and CSS code from HTML code in a Visual Studio C++ project?

In my project I have several HTML-JavaScript-CSS code and I want to split them into different files. 在我的项目中,我有几个HTML-JavaScript-CSS代码,我想将它们分成不同的文件。 The control I am using is derived from ATL CAxWindow. 我使用的控件是从ATL CAxWindow派生的。

Environment: Microsoft Visual Studio 2010 Professional. 环境:Microsoft Visual Studio 2010专业版。

Programming Language: C++, JavaScript, HTML. 编程语言:C ++,JavaScript,HTML。

The problema arises when I try to separaste the scripting and style codes into separate files. 当我尝试将脚本和样式代码分成单独的文件时,就会出现问题。 The HTML document generated won't detect those files since they're not included in the resources of the Project, like the HTML document is. 生成的HTML文档不会检测到这些文件,因为它们没有像HTML文档那样包含在Project的资源中。

Do you know how can I include those? 你知道我怎么包括那些吗?

Thanks beforehand. 预先感谢。

Actually you have to include both, .css and .js files in the Visual Studio environment by adding the resources to the project. 实际上,您必须通过将资源添加到项目中来在Visual Studio环境中同时包含.css和.js文件。 This will allow to the system to include those on the generated solution and make the files accessible for your HTML code. 这将使系统将那些文件包含在生成的解决方案中,并使文件可用于您的HTML代码。

Once you have included the files on your solution, a number identifying the resource will appear on the resources header file. 将文件包含在解决方案中后,标识资源的数字将出现在资源头文件中。 You have to include that resource identificator as the source for the javascript and css files. 您必须包括该资源标识符作为javascript和css文件的源。 For instance: 例如:

In case my ID is -> 1
I have to write on my html ->  <link rel="stylesheet" type="text/css" href="./1">

Hope it helps! 希望能帮助到你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将工作 HTML、CSS、Javascript 代码从 Codepen 传输到 Visual Studio 代码和浏览器 - How to Transfer Working HTML, CSS, Javascript Code from Codepen to Visual Studio Code and Browser 如何从CSS代码中分离html代码 - How to separate html code from css code 在 Visual Studio Code 中格式化 html 代码,以便属性在单独的行上? - Format html code in Visual Studio Code such that attributes are on separate lines? html 未链接到 Visual Studio Code 中的 css 文件 - html not linking to css file in Visual Studio Code HTML CSS和Visual Studio Professional-2015(请勿与Visual Studio代码混淆) - HTML CSS and Visual Studio Professional - 2015 (Not to be confused with Visual Studio Code) 如何在 Visual Studio 代码上混合/添加 Javascript 代码到 Html 代码? - How to mix/add Javascript code to Html code on Visual studio code? 将HTML / JavaScript代码分开 - Separate HTML/Javascript code into Visual Studio 代码 html css javascript 程序未在我的浏览器中正确显示 - visual studio code html css javascript program not appearing correctly in my browser Visual Studio Code 扩展:HTML 预览; 外部 CSS 不起作用 - Visual Studio Code Extension: HTML Preview; External CSS it's not working Visual Studio折叠HTML代码 - Visual Studio collapsing html code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM