By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,131 Members | 1,749 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,131 IT Pros & Developers. It's quick & easy.

window.open works in Firefox but not IE6/7

P: 20
Hi, i have tried this code in FireFox and it works great. However , it seems to fail in IE6/7. I have no idea and looking for help here. Please advice. Thank you.
Expand|Select|Wrap|Line Numbers
  1. <a
  2. ONCLICK="window.open('http://www.google.com,'height=180','width=250','location=no','menubar=no','resizable=no','scrollbars=yes','status=no','toolbar=no')" href="javascript:void(0)">
  3. Whois Agent local</a>
Jan 7 '08 #1
Share this Question
Share on Google+
6 Replies


Expert 100+
P: 785
This code is programmed bad. Why do you need an "onclick"-event if your "href" is already reacting to the click? You disabled the clicking by using href="javascript:void(0)". So no wonder the browser gets confused and reacts differently on this error.
Just use
Expand|Select|Wrap|Line Numbers
  1. <a href="javascript:window.open(...)>Whois Agent local</a>
and it should work in all browsers.

If it still does not work, then check your configuration (for example if you have disabled javascript in your brower)

Hi, i have tried this code in FireFox and it works great. However , it seems to fail in IE6/7. I have no idea and looking for help here. Please advice. Thank you.
Expand|Select|Wrap|Line Numbers
  1. <a
  2. ONCLICK="window.open('http://www.google.com,'height=180','width=250','location=no','menubar=no','resizable=no','scrollbars=yes','status=no','toolbar=no')" href="javascript:void(0)">
  3. Whois Agent local</a>
Jan 7 '08 #2

P: 20
Thank you Chaarmann, Your method seems to be more effective way to the javascript. However, i am still facing the same problem even using your suggested way.

here is my function in php:
Expand|Select|Wrap|Line Numbers
  1. function open_me1(){
  2. window.open('http://www.google.com','height=300','width=250','location=no','menubar=no','resizable=no','scrollbars=yes','status=no','toolbar=no');
javascript:
Expand|Select|Wrap|Line Numbers
  1. <a href="javascript:open_me1();">Click To google</a><br />
I manage to call the function in FireFox with no error message recorded in Error Console. On the other hand, IE6/7 the error message is invalid argument. This is weird.
Jan 7 '08 #3

acoder
Expert Mod 15k+
P: 16,027
window.open() only has 3 or 4 parameters. The first is the URL. The second is the name of the window. The third specifies the properties. You've split these up into their own arguments - they should be grouped together as one. See, for example, this link.
Jan 7 '08 #4

acoder
Expert Mod 15k+
P: 16,027
This code is programmed bad. Why do you need an "onclick"-event if your "href" is already reacting to the click? You disabled the clicking by using href="javascript:void(0)".
You should always use the href of a link in case JavaScript is disabled. It should really point to a real URL (in this case google.com). In the onclick, you can prevent the browser following the href link using return false. If you program like this, it will work whether JavaScript is enabled or not.
Jan 7 '08 #5

Expert 100+
P: 785
You should always use the href of a link in case JavaScript is disabled. It should really point to a real URL (in this case google.com). In the onclick, you can prevent the browser following the href link using return false. If you program like this, it will work whether JavaScript is enabled or not.
Cool, I learned something new today. Especially that you can disable the href by returning "false" in your onClick. But that also means that the onClick is executed first. Is this the case in all common browsers?
Jan 8 '08 #6

acoder
Expert Mod 15k+
P: 16,027
Cool, I learned something new today. Especially that you can disable the href by returning "false" in your onClick. But that also means that the onClick is executed first. Is this the case in all common browsers?
Yes, if JavaScript is enabled. If it's disabled, the href link will be followed. See these usability issues/tips for more information.
Jan 8 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.