网站更改了我的链接目标:如何更改它?

时间:2021-11-27 20:28:20

I'm using Instructure Canvas—a learning management system—to code a web page. I can use JavaScript but it has to be in an external file, not embedded in the HTML.

我正在使用Instructure Canvas--一种学习管理系统 - 来编写网页代码。我可以使用JavaScript但它必须在外部文件中,而不是嵌入在HTML中。

I want to have a few buttons linking to videos that show up in an iframe on the current page like so:

我想要一些按钮链接到当前页面上iframe中显示的视频,如下所示:

<a class="iframelink" href="https://player.vimeo.com/video/90612" target="vimeobox">watch</a>

The problem is that the learning management system changes the links to pop up in an external tab like so:

问题是学习管理系统将链接更改为在外部选项卡中弹出,如下所示:

<a class="external" target="_blank" href="https://player.vimeo.com/video/90612">watch</a>

Is there any way to prevent this?

有什么方法可以防止这种情况吗?

1 个解决方案

#1


After the learning management system has generated the video links, run the following JavaScript function:

学习管理系统生成视频链接后,运行以下JavaScript函数:

function changeLinks() {
  var links = document.getElementsByTagName('a');
  for (var i = 0; i < links.length; ++i) {
    var link = links[i];
    if (link.className == 'external') {
      link.className = 'iframelink';
      link.target = 'vimeobox';
    }
  }
}

changeLinks();
<a class="external" target="_blank" href="https://player.vimeo.com/video/90612">watch</a>

This script takes all the anchor tags on the page that have class="external" and modifies them by changing the class and target.

此脚本获取页面上具有class =“external”的所有锚标记,并通过更改类和目标来修改它们。

#1


After the learning management system has generated the video links, run the following JavaScript function:

学习管理系统生成视频链接后,运行以下JavaScript函数:

function changeLinks() {
  var links = document.getElementsByTagName('a');
  for (var i = 0; i < links.length; ++i) {
    var link = links[i];
    if (link.className == 'external') {
      link.className = 'iframelink';
      link.target = 'vimeobox';
    }
  }
}

changeLinks();
<a class="external" target="_blank" href="https://player.vimeo.com/video/90612">watch</a>

This script takes all the anchor tags on the page that have class="external" and modifies them by changing the class and target.

此脚本获取页面上具有class =“external”的所有锚标记,并通过更改类和目标来修改它们。