简体   繁体   English

如何在 html 文件中声明一个全局变量,该变量可以被另一个 html 文件以及同一个项目使用

[英]How to declare a global variable in html file which can be used by another html file as well of same project

I have 2 html files我有 2 个 html 文件

file 1 : That has pop up form using data fancy box文件 1:使用数据花式框弹出表单

file 2 : where pop-up form has called at different place on same page文件 2 : 弹出窗体在同一页面的不同位置调用

I want to declare a global variable in file 2 which will be called in file 1 to put conditions further.我想在文件 2 中声明一个全局变量,它将在文件 1 中调用以进一步放置条件。 Can anyone tell me how is it possible?谁能告诉我怎么可能?

Create a common Js File and declare the variable in that file.创建一个通用的 Js 文件并在该文件中声明变量。

Import that js file in two index files and you can use that variable.在两个索引文件中导入该 js 文件,您可以使用该变量。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM