使用 SPFX 扩展将 <META HTTP-EQUIV="refresh" CONTENT="3000"> 添加到我的页面

问题描述

我想强制我的现代页面每 3000 秒刷新一次 >> 所以我开发了一个 spfx 扩展 >> 在我的 .ts 中我添加了以下代码:-

export default class HelloWorldApplicationCustomizer
  extends BaseApplicationCustomizer<IHelloWorldApplicationCustomizerProperties> {

    @override

    public onInit(): Promise<void> {
      Log.info(LOG_SOURCE,`Initialized ${strings.Title}`);
  
      const cssUrl: string = this.properties.cssurl;
      const scriptUrl: string = this.properties.scripturl;
      if (cssUrl) {
          // inject the style sheet
          const head: any = document.getElementsByTagName("head")[0] || document.documentElement;
          let customStyle: HTMLLinkElement = document.createElement("link");
          customStyle.href = cssUrl;
          customStyle.rel = "stylesheet";
          customStyle.type = "text/css";

          const head2: any = document.getElementsByTagName("head")[0] || document.documentElement;
          let customScript: HTMLLinkElement = document.createElement("link");
          customScript.href = scriptUrl;
          customScript.rel = "script";
          customScript.type = "text/javascript";

          head.insertAdjacentElement("beforeEnd",customStyle);
          head2.insertAdjacentElement("beforeEnd",'<Meta HTTP-EQUIV="refresh" CONTENT="3000">');
      }
  
      return Promise.resolve();
    }

现在,当我将 SPFX 添加到我的网站时,页面不会每 3000 秒加载一次..所以似乎 head2.insertAdjacentElement("beforeEnd",'<Meta HTTP-EQUIV="refresh" CONTENT="3000">'); 没有任何效果.. 虽然我有一个正确应用的 customStyle.. 任何建议?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)