I would like to place a single piece of JavaScript at the top of m
intranet page/s to tell every link on that page to open in a certai
target window, depending on the "hostname".
Suppose my intranet address was http://intranet_01
If I wanted all of the links on a page that were linked to files withi
the intranet to open in a new window, would I place a piece of cod
like this at the top of the page:
<script language = "JavaScript ">
if (links.hostname == 'intranet_01') {
link.target = '_blank';
}
return true;"
</script>
Please tell me if any correction needs to be made to this, such as i
it should say this.target or links.target instead of link.target.
Also, if I wanted all other links that are NOT in the intranet to ope
in the same window, I would then have to place an "else" statement i
there somewhere too such as else link.target = "_top";
Where would this else statement go within my script? I am new to JS an
do not completely know exactly where each piece of code should go.
Thanks
HGJ
Comment