Go Premium for a chance to win a PS4. Enter to Win

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4790
  • Last Modified:

simple window.open gives me "Invalid argument" error only in Internet explorer

can someone tell me why in the following code, first link work and secont doesnt (only in internet explorer). how can i tweak it?

thanks in advance

<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/JavaScript">
function MM_openBrWindow(theURL,winName,features) { //v2.0

function open_postcode() {
      var postcode = document.getElementById ('WwwCustomerPostcode');
      var ppp = postcode.value;
      var sss = "/www_customers/codeplus/"+ppp;//+postcode.value;//+'/'+property.value;
      MM_openBrWindow(sss,"Spring Harvest Holidays","width=780,height=600");

<p><a href="javascript:MM_openBrWindow('/customers/show/2','ddd','width=300,height=200')">first link</a>
  <br />
    <a href="javascript:open_postcode()">second link</a></p>
<form id="form1" name="form1" method="post" action="">
  <input type="text" name="textfield" id="WwwCustomerPostcode" />
1 Solution
Michel PlungjanIT ExpertCommented:

Although what is the point to pass 3 parameters to a function that use the parameters to call window.open with the same 3 parameters?

Also do yourself a favour and use

function open_postcode() {
     var postcode = document.getElementById ('WwwCustomerPostcode');
     var ppp = postcode.value;
     var sss = "/www_customers/codeplus/"+ppp;//+postcode.value;//+'/'+property.value;
     var w=window.open(sss,"Spring_Harvest_Holidays","width=780,height=600");
     if (!w) alert('Please allow popups')
     return false; // cancel the link

<a href="/customers/show/2" target="ddd"
onClick="w=window.open(this.href,this.target,'width=300,height=200'); return (w)?false:true">first link</a>

<a href="#" onClick="return open_postcode()">second link</a>

to handle popup blockers and to not unload the page when clicking a link that does not leave the page

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now