window.open(URL,name,specs,replace) Issue with IE9

Hello Every one

Im using window.open(URL,name,specs,replace) to open a new page
it works fine with Chrome V22 and Firefox 12
But when i use it with IE9 it gives me a strange behavior

When i click it open a new page but the original page changes to the main root of the file index

Did anyone face such a problem

You may be having a side-effect from how you’re doing it, and possibly from the web browser performing the default behaviour for a link.

In other words, please show us the HTML and JavaScript for what you’re doing.

Well this is the code i used

function open_win(id, sub_id)
{
window.open('open_att_form.php?level=' + id + '&sub_id=' + sub_id,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=660, height=500");
}

And what are you doing to call that function?


<a onclick="open_win(1,7)" href="">Add<img src="layout/add.png" alt=""/></a>
<a onclick="open_win(1,8)" href="">Add<img src="layout/add.png" alt=""/></a>
<a onclick="open_win(1,9)" href="">Add<img src="layout/add.png" alt=""/></a>

Okay, so there’s the problem. The web browser’ default action is not being cancelled anywhere. Return false from the open_win function to prevent the web browser from performing its default action when you click on the link, so that it is only the scripting that performs your desired action instead.

Thanks Paul
I did this


function open_win(id, sub_id)
{
	window.open('open_att_form.php?level=' + id + '&sub_id=' + sub_id,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=660, height=500");
	
	return false;
}

Still it did not work!
What im doing wrong…

The other thing that’s not right is that the href attribute is empty. When it’s empty the page reloads. With something in there, commonly “#”, no such trouble occurs.

This is the code and IE Version

My IE Version 9.0.8112
Update Version 9.0.10



JS Code

<script type="text/javascript">
function open_win(id, sub_id)
{
	window.open('open_att_form.php?level=' + id + '&sub_id=' + sub_id,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=660, height=500");
	
	return false;
}
</script>


HTML Code

<a onclick="open_win(1,5)" href="">Add<img src="img/layout/add.png" alt=""/></a>



Update::::::

Now i get it BUT what should i do?
Im using JS to send the data not the link it self…

You need to fix the href attribute of your link. When the href attribute is empty, it causes the page to reload. This occurs regardless of whether you use scripting or not.

When you intend for the link to be controlled with scripting, you should use “#” for the link instead.

You must return the handler’s return value:


<a onclick="[B]return[/B] open_win(1,5)" href="">Add<img src="img/layout/add.png" alt=""/></a>

Aha! That’s the missing bit of the puzzle. Thanks for helping to spot that.

Thanks guys