<html>
<body>
<a name="list">the list</a>
<ul>
<li><a href="http://google.com">http://google.com</a></li>
<li><a href="/tutorial">/tutorial.html</a></li>
<li><a href="local/path">local/path</a></li>
<li><a href="ftp://ftp.com/my.zip">ftp://ftp.com/my.zip</a></li>
<li><a href="http://nodejs.org">http://nodejs.org</a></li>
<li><a href="http://internal.com/test">http://internal.com/test</a></li>
</ul>
<script>
let link = document.querySelector('a');
link.style.color = 'orange';
let links = document.query.querySelectorAll('a');
for (let link of links){
let href = link.getAttribute('href');
//href attribute is full URL
if(!href) continue;
if(!href.includes('://')) continue;
//if its internal resourse, it's out of condition, skip
if (href.startWith('http://internal.com')) continue;
//which means also internal resourse, skip
link.style.color = 'orange';
}
</script>
</body>
</html>
<body>
<a name="list">the list</a>
<ul>
<li><a href="http://google.com">http://google.com</a></li>
<li><a href="/tutorial">/tutorial.html</a></li>
<li><a href="local/path">local/path</a></li>
<li><a href="ftp://ftp.com/my.zip">ftp://ftp.com/my.zip</a></li>
<li><a href="http://nodejs.org">http://nodejs.org</a></li>
<li><a href="http://internal.com/test">http://internal.com/test</a></li>
</ul>
<script>
let link = document.querySelector('a');
link.style.color = 'orange';
let links = document.query.querySelectorAll('a');
for (let link of links){
let href = link.getAttribute('href');
//href attribute is full URL
if(!href) continue;
if(!href.includes('://')) continue;
//if its internal resourse, it's out of condition, skip
if (href.startWith('http://internal.com')) continue;
//which means also internal resourse, skip
link.style.color = 'orange';
}
</script>
</body>
</html>
/*
task2
*/
댓글
댓글 쓰기