Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想为我网站上的每个 html 页面包含一个基于页面名称或另一个使用 Javascript 的唯一元素的文件。
该脚本需要识别元素然后加载正确的文件。
我的网站页面以扩展名 .html 结尾——如果我可以将它们更改为 .php 我会并且我会设置,但我无法更改结构。
例如,一个脚本会检查beads.html 中的唯一元素,然后它会加载与该元素关联的beads-nav.html 文件。珠宝.html 将加载珠宝导航.html 文件等。
您可以通过 ajax 加载外部页面。
使用 jquery 可以像这样简单:$('#result').load('ajax/test.html');
$('#result').load('ajax/test.html');
取自这里。