# Solved: Open external link in new window/tab?



## DaveSS (Jun 18, 2002)

Hi folks,

On dreamweaver I was typing in external links into it's link field box. I now see that when a user clicks on this link, it takes them away from my site.

I would like it so when link is clicked it will open up a new tab or window.

Firstly, is this possible without manually writing code for each link?

I think this is the code to use 
<a href="http://www.smarty.net" target="_blank">www.smarty.net

But I find it easier and faster just to write something into dreamweavers link field box. Is this possible?

Also, is there a difference in the code in opening in a tab or window?

Dave


----------



## chiliwormeater45 (Jul 2, 2007)

```
<base target="_blank">
```
I believe that should work.


----------



## namenotfound (Apr 30, 2005)

chiliwormeater45 said:


> ```
> <base target="_blank">
> ```
> I believe that should work.


Won't that make ALL links open in new windows (including internal ones)?



DaveSS said:


> Also, is there a difference in the code in opening in a tab or window?


It's how the user sets up their browser to open it in a new window or new tab.


----------



## DaveSS (Jun 18, 2002)

Thanks, but is that not the same as

<a href="http://www.smarty.net" target="_blank">www.smarty.net ?

In DW you just highlight the text, and then enter the url into a field. I am trying to find out if there is a way to just enter a code in this way rather than direct to the html?

I can enter in the above code no problem and it works in opening a new tab. But was looking for something specific my DW prob?


----------



## namenotfound (Apr 30, 2005)

DaveSS said:


> Thanks, but is that not the same as
> 
> www.smarty.net ?
> 
> ...


Remember to always close your tags (otherwise all text that appears on the page after that, would be linked to smarty)


```
<a href="http://www.smarty.net" target="_blank">www.smarty.net[/URL]
```
I'm not familiar with DW, but there *should* be an option to choose a target...

If you use to do this to all links, like chilli suggested, keep in mind that ALL links will get a new window (not just external ones). You could do that instead of editing every link, but it would effect ALL links. goes between and

Here is an example of how you'd use it http://www.w3schools.com/TAGS/tag_base.asp


----------



## DaveSS (Jun 18, 2002)

Ah thanks for the explanation , I see how it works now. So no, I just want external links to open in a new tab. 

Yea there's a target field in DW. But it will only except a url, when I put the code in there it tries to locate the url locally. :-(

I guess that means the only way to do it is to manually edit them all in html? 

By any chance would you know how to create a link from one page that opens up on an internal link on another page?

I have a page with internal links, in other words a user can click on a heading and it will zip them off down the same page. I have this working fine. But would like to get it working so that on another page, some one can click on the heading, and be taken to the new page half way down the page? 

I can't find a reference for this type of link anywhere?


----------



## namenotfound (Apr 30, 2005)

You mean a bookmark link? (where a link at the top jumps to some text in the middle of the same page)

First put an ID in the element you want to jump to

Some Text

To link to it, put Click to jump to some text

This will work for another page too. Say you're on page1 and want to link to some text on page2. Provided page2 has an ID to jump to, it's like ths:

jump to some text on page 2


----------



## DaveSS (Jun 18, 2002)

Aha. Very good!

I just got it too work too. I noticed the URL in the browser gave me what I was looking for!



> mysite.com/Countries/Portugal.html#Some%20memorable%20places%20I%20have%20been


I was missing the # symbol.

Thanks a lot for all the link help, it's been a big plus!!

Dave


----------

