Solved

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

Posted on 2006-10-24
1
4,767 Views
Last Modified: 2012-08-13
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">
<head>
<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
  window.open(theURL,winName,features);
}

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

<body>
<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="">
  <label>WwwCustomerPostcode
  <input type="text" name="textfield" id="WwwCustomerPostcode" />
  </label>
</form>
</body>
</html>
0
Comment
Question by:kirez
1 Comment
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 150 total points
ID: 17801403
"Spring_Harvest_Holidays"

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;
     alert(sss);
     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>

and
<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
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now