<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
 
<html> 
<head> 
	<title>JavaScript Window Open Example</title> 

</head> 
 
<body> 
<SCRIPT language="JavaScript1.2"> 
function openwindow()
{

	location('http://www.google.com','_self');
}
</SCRIPT> 
<P> 

 <input type="button" value="Replace Me!" onClick=" window.location = 'http://www.google.com/' ; ">

<A href="javascript: openwindow()" >LINK 1</A> 
</P> 
<P>Back to the article:<br> 
<a href="http://google.lk" target="_self">LINK 2</a> 
</P> 
</body> 
</html>

In this There are 2 links, in the 1st link, when we click on it, the web page will open in a new window. and when we right click on the link the (open link in new tab/window) popup doesn't appear.

In the 2nd link, when i click on it, it will open up in the same window, and also when i right click on it the popup that shows the (open link in new tab/window) popup appears.

So what i want to do is to edit the Javascript in the 1st link to have both functions;
1.) when a user click on the link, the web page should open in the same window
2.) when a user R- Click on the link, the popup should show up (open link in new tab/window).

Can some one please help me here, i'm lost :(

I dont think this will be possible. Whenever you right click on a link and try to open it in new tab/window it will open with the value set to the 'href' attribute

Try attaching this function to your link. Replace url with your url and name with whatever name you want.

function(e){
var leftBtn;
if(!e){
var e = window.event;
leftBtn = 1; //IE detects left click differently
}else{
leftBtn = 0;
}
if(e.button===2){ //Right click
window.open(url, name)
}else if(e.button===leftBtn){ //Left click
window.location = url;
}