<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>getFullYear &#8211; カミュプリィの雑多なメモ</title>
	<atom:link href="https://www.commuply.co.jp/technic/memo/tag/getfullyear/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.commuply.co.jp/technic/memo</link>
	<description></description>
	<lastBuildDate>Thu, 26 Sep 2024 08:01:23 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>

<image>
	<url>https://www.commuply.co.jp/technic/memo/wp-content/uploads/site-icon-150x150.png</url>
	<title>getFullYear &#8211; カミュプリィの雑多なメモ</title>
	<link>https://www.commuply.co.jp/technic/memo</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>[JavaScript]Copyrightの年を常に今年に書き換えます</title>
		<link>https://www.commuply.co.jp/technic/memo/addeventlistener/</link>
		
		<dc:creator><![CDATA[ume]]></dc:creator>
		<pubDate>Tue, 01 Feb 2022 04:20:56 +0000</pubDate>
				<category><![CDATA[未分類]]></category>
		<category><![CDATA[addEventListener]]></category>
		<category><![CDATA[Copyright]]></category>
		<category><![CDATA[getFullYear]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[textContent]]></category>
		<guid isPermaLink="false">https://www.commuply.co.jp/technic/website/?p=131</guid>

					<description><![CDATA[　ページの末尾にCopyrightを記載したサイトを見かけます。ちなみに『©』は『&#38;copy;』と書くことで表示できます。 Copyright © 2022 カミュプリィ (Commuply Inc.) 年が入っ [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">　ページの末尾にCopyrightを記載したサイトを見かけます。ちなみに『©』は『&amp;copy;』と書くことで表示できます。</p>



<p class="wp-block-paragraph"><code>Copyright © 2022 カミュプリィ (Commuply Inc.)</code></p>



<p class="wp-block-paragraph">年が入っているため更新しないでおくと、何年もサイトを更新していないように思われてしまいます。<br>自動更新できないかなぁと考えました。</p>



<h2 class="wp-block-heading" id="html">HTML</h2>



<p class="wp-block-paragraph">　htmlのhead部分に使用するジャバスクリプトのファイルを記載します。</p>



<p class="wp-block-paragraph"><code>&lt;head&gt;<br>&lt;script type="text/javascript" src="./loadevent.js"&gt;&lt;/script&gt;<br>&lt;/head&gt;</code></p>



<p class="wp-block-paragraph">　つぎに、実際に表示される年の数字部分に『currentyear』と名前を付けます。この名前をつけた部分をジャバスクリプトで書き換えます。</p>



<p class="wp-block-paragraph"><code>&lt;span class="currentyear"&gt;2022&lt;/span&gt;</code></p>



<h2 class="wp-block-heading" id="javascript">JavaScript</h2>



<p class="wp-block-paragraph">　『currentyear』を今年へ書き換える関数を書きます。</p>



<p class="wp-block-paragraph">function updateyear() {<br>   let currentyear = document.getElementsByClassName(&#8216;currentyear&#8217;);<br>   for(var i = 0, len = currentyear.length|0; i &lt; len; i = i + 1|0) {<br>      currentyear[i].textContent = (new Date()).getFullYear();<br> <code>  }<br>}</code></p>



<p class="wp-block-paragraph">　つぎに、htmlが表示されたときに『updateyear』を呼び出す設定をします。</p>



<p class="wp-block-paragraph"><code>window.addEventListener('load', updateyear);</code></p>



<p class="wp-block-paragraph"></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
