MediaWiki:Common.js:修订间差异
跳转到导航
跳转到搜索
标签:替换 撤销 |
无编辑摘要 |
||
第1行: | 第1行: | ||
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */ | /* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */ | ||
// 检查当前页面的标题或 URL 是否符合条件 | |||
if (mw.config.get('wgCanonicalSpecialPageName') === 'User:Selfice/sandbox/首页') { // 替换为你想限制的页面名称或条件 | |||
// 等待 DOM 完全加载 | |||
document.addEventListener("DOMContentLoaded", function() { | |||
// 获取父元素和两个子元素 | |||
const parentElement = document.querySelector('.grid_block'); | |||
const firstChild = parentElement.children[0]; | |||
const secondChild = parentElement.children[1]; | |||
// 获取第一个子元素的高度 | |||
const firstChildHeight = firstChild.offsetHeight; | |||
// 将第一个子元素的高度应用到第二个子元素的 max-height 上 | |||
secondChild.style.maxHeight = firstChildHeight + 'px'; | |||
}); | |||
} |
2025年1月3日 (五) 23:06的版本
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */ // 检查当前页面的标题或 URL 是否符合条件 if (mw.config.get('wgCanonicalSpecialPageName') === 'User:Selfice/sandbox/首页') { // 替换为你想限制的页面名称或条件 // 等待 DOM 完全加载 document.addEventListener("DOMContentLoaded", function() { // 获取父元素和两个子元素 const parentElement = document.querySelector('.grid_block'); const firstChild = parentElement.children[0]; const secondChild = parentElement.children[1]; // 获取第一个子元素的高度 const firstChildHeight = firstChild.offsetHeight; // 将第一个子元素的高度应用到第二个子元素的 max-height 上 secondChild.style.maxHeight = firstChildHeight + 'px'; }); }