B站热搜榜单初步完成;网页标题跟随子iframe变化而变化
This commit is contained in:
24
index.html
24
index.html
@@ -5,7 +5,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>微博热搜</title>
|
||||
<title>热搜榜单</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
@@ -71,7 +71,7 @@
|
||||
<body>
|
||||
<div class="container">
|
||||
<div id="iframe-container">
|
||||
<!-- <iframe src="html/weibo.html" frameborder="0"></iframe> -->
|
||||
<!-- <iframe id="main-iframe" src="html/weibo.html" frameborder="0"></iframe> -->
|
||||
</div>
|
||||
<div id="float-container" class="bt">
|
||||
<!-- <div class="navbar-item" targetPage="weibo_hotband">
|
||||
@@ -88,18 +88,18 @@
|
||||
icon: './html/assets/image/weibo.svg',
|
||||
icon_scale: 1,
|
||||
},
|
||||
'bilibili_rank': {
|
||||
title: 'B站排行',
|
||||
// url: 'html/bilibili_rank.html',
|
||||
icon: './html/assets/image/icon_rank.png',
|
||||
icon_scale: 1,
|
||||
},
|
||||
'bilibili_hotband': {
|
||||
title: 'B站热搜',
|
||||
// url: 'html/bilibili_hotband.html',
|
||||
icon: './html/assets/image/bilibili.svg',
|
||||
icon_scale: 0.87,
|
||||
},
|
||||
'bilibili_rank': {
|
||||
title: 'B站排行',
|
||||
// url: 'html/bilibili_rank.html',
|
||||
icon: './html/assets/image/icon_rank.png',
|
||||
icon_scale: 1,
|
||||
},
|
||||
};
|
||||
// 渲染导航栏
|
||||
for (let key in pages) {
|
||||
@@ -118,7 +118,7 @@
|
||||
<script>
|
||||
let navbarItems = document.querySelectorAll('.navbar-item');
|
||||
let iframeContainer = document.querySelector('#iframe-container');
|
||||
let iframe = document.querySelector('iframe');
|
||||
let iframe = document.querySelector('#main-iframe');
|
||||
navbarItems.forEach(item => {
|
||||
item.addEventListener('click', () => {
|
||||
// 已选中项再次点击,不执行操作
|
||||
@@ -147,9 +147,15 @@
|
||||
if (iframe)
|
||||
iframe.remove();
|
||||
iframe = document.createElement('iframe');
|
||||
iframe.id = "main-iframe";
|
||||
iframe.src = url;
|
||||
iframe.setAttribute('frameborder', '0');
|
||||
iframeContainer.appendChild(iframe);
|
||||
|
||||
iframe.addEventListener('load', function (event) {
|
||||
console.log(event);
|
||||
document.title = document.getElementById("main-iframe").contentWindow.document.title + " | 热搜榜单"
|
||||
}, true);
|
||||
}
|
||||
|
||||
// 根据 URL 参数切换页面
|
||||
|
||||
Reference in New Issue
Block a user