閲覧数:571
投稿日:2020-04-07
更新日:2020-04-07
URLで条件分岐
コード
if(location.pathname =='/a.php'){ } //複数 if((location.pathname =='/a.php')||(location.pathname =='/b.php')){ } //使用例 if((location.pathname =='/a.php')||(location.pathname =='/b.php')){ if (document.readyState === 'loading') { // Loading hasn't finished yet document.addEventListener('DOMContentLoaded', userFunc); } else { // `DOMContentLoaded` has already fired userFunc(); } }
結果
URLで条件分岐