You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用jQuery修改iframe的src:移除指定后缀并添加rel=0(无法直接编辑HTML)

修改iframe src属性的解决方案(无法直接编辑HTML时)

Got it, since you can't edit the HTML code directly, we can use JavaScript to dynamically tweak that iframe's src attribute exactly as you need after the page loads. Here's a straightforward approach:

Step-by-Step Breakdown

  • Target the iframe using its unique id (VideoContent in your case)
  • Extract the portion of the src URL before -C87LOjwkRw?
  • Append rel=0 to this base segment to form the desired final URL
  • Assign the modified URL back to the iframe's src property

Working Code Snippet

// Wait for the page to fully load so the iframe exists in the DOM
document.addEventListener('DOMContentLoaded', function() {
  // Grab the target iframe element
  const videoIframe = document.getElementById('VideoContent');
  
  if (videoIframe) {
    // Get the current src value
    let originalSrc = videoIframe.src;
    // Locate the specific string we need to cut after
    const targetMarker = '-C87LOjwkRw?';
    const cutOffPoint = originalSrc.indexOf(targetMarker);
    
    if (cutOffPoint !== -1) {
      // Build the new src: keep everything up to the marker, then add rel=0
      const newSrc = originalSrc.slice(0, cutOffPoint + targetMarker.length) + 'rel=0';
      // Update the iframe's src attribute
      videoIframe.src = newSrc;
    }
  }
});

How to Implement This

You can drop this code inside a <script> tag at the bottom of your HTML page, or run it directly in your browser's developer console for a quick one-time fix. The DOMContentLoaded event ensures the code only runs after all page elements have loaded, so we won't try to access the iframe before it exists in the DOM.

内容的提问来源于stack exchange,提问作者Jenny

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 08:13:53