35 lines
843 B
Markdown
35 lines
843 B
Markdown
importance: 3
|
|
|
|
---
|
|
|
|
# Make external links orange
|
|
|
|
Make all external links orange by altering their `style` property.
|
|
|
|
A link is external if:
|
|
- Its `href` has `://` in it
|
|
- But doesn't start with `http://internal.com`.
|
|
|
|
Example:
|
|
|
|
```html run
|
|
<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>
|
|
// setting style for a single link
|
|
let link = document.querySelector('a');
|
|
link.style.color = 'orange';
|
|
</script>
|
|
```
|
|
|
|
The result should be:
|
|
|
|
[iframe border=1 height=180 src="solution"]
|