鲨鱼58
标题:
通过js添加样式代码
[打印本页]
作者:
刀哥
时间:
2024-8-12 20:30
标题:
通过js添加样式代码
<script>
// 获取当前URL
var currentURL = window.location.href;
// 检查URL是否包含 "special-url"
if (currentURL.includes("special-url")) {
// 插入内联CSS
var style = document.createElement("style");
style.innerHTML = `
body {
background-color: #f0f0f0;
color: #333;
}
`;
document.head.appendChild(style);
// 输出提示信息
console.log("URL 包含 'special-url'!");
} else {
console.log("URL 不包含 'special-url'.");
}
</script>
复制代码
欢迎光临 鲨鱼58 (https://www.shayu58.com/)
Powered by Discuz! X3.5