嵌入 Google 日历
Google 日历 ( Google Calendar ) 是非常方便的线上日历应用程序,不论是任何的操作系统,只需要打开浏览器就能看到自己所需的日历行程,这篇教学会介绍如何透过 HTML 的实作,将 Google 日历加到网页中。
将 Google 日历发布到网络
登录 Google 账号后前往 Google 日历,使用现成的日历或新增一个新的日历,点选左侧日历后方的“...”,选择“设定和共用”。
进入设定画面后,下拉前往“活动的存取权限”区块,勾选“公开这个日历”将日历发布到网络上。
将画面往下到“整合日历”区域,找到“内嵌程序码”的程序码,就是待会要嵌入网页的程序码 ( 点选“自订”后会将所有的日历整合到同一份程序码里,如果只是单一日历不用点选 )。
嵌入 Google 日历
复制 Google 日历的程序码,贴到网页中的 <body> 里,执行后就会看见 Google 日历出现在网页中。
<iframe src="https://calendar.google.com/calendar/embed?src=fed68789afd73deb7258b05a29339d3315279772e215072bf5cbd26f1ca866fa%40group.calendar.google.com&ctz=Asia%2FTaipei" style="border: 0" width="800" height="600" frameborder="0" scrolling="no"></iframe>
Google 日历嵌入网址参数与属性
嵌入 Google 日历之后,可以透过网址参数和 iframe 的属性设定 Google 日历,常用的设定参考:
iframe 属性
| 属性 | 说明 |
|---|---|
| width | 宽度 ( 可使用 CSS 取代 )。 |
| height | 高度 ( 可使用 CSS 取代 )。 |
| src | Google 日历网址。 |
| frameborder | iframe 边框 ( 可使用 CSS 调整 )。 |
| scrolling | 是否可以卷动,默认 no,设定 yes 会出现卷轴。 |
网址参数
| 参数 | 说明 |
|---|---|
| wkst | 设定日历的开头是星期几,默认星期天 1,星期一到星期六分别是 2~7。 |
下方的 HTML 会用两组不同网址参数和属性的程序码,加载同样的一份 Google 试算表图表,最后呈现的结果就会是一个星期天开头,另外一个是星期三开头。
<iframe src="https://calendar.google.com/calendar/embed?src=fed68789afd73deb7258b05a29339d3315279772e215072bf5cbd26f1ca866fa%40group.calendar.google.com&ctz=Asia%2FTaipei" style="border: 0" width="800" height="600" frameborder="0" scrolling="no"></iframe>
<iframe src="https://calendar.google.com/calendar/embed?src=fed68789afd73deb7258b05a29339d3315279772e215072bf5cbd26f1ca866fa%40group.calendar.google.com&ctz=Asia%2FTaipei&wkst=3" style="border: 0" width="800" height="600" frameborder="0" scrolling="no"></iframe>
微信扫码关注
抖音扫码关注