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

script call works in FF not in IE.......sigh

P: 219
I'm trying to get this function to work in IE, it works fine in Firefox. When I click the below link I get an error in IE.

Error: Object expected

Expand|Select|Wrap|Line Numbers
  1.             <li><a href=javascript:validate("admin_v2.cfm")>Admin</a></li>
Expand|Select|Wrap|Line Numbers
  1. function validate(url){
  2.     password = prompt("Please enter the password","");
  3.     if (password=="'") {
  4.         settings="toolbar=no,location=no,directories=no,"+
  5.                  "status=no,menubar=no,scrollbars=yes,"+
  6.                  "resizable=yes,width=500,height=300";
  7.         //commentWindow ='http://intweb/codegrey/comments.cfm?id=' + comments,'CommentWindow',settings);
  8.         location.href = url;
  9.     }
  10.     else
  11.         alert("Invalid password!");
  12. }
Yes I realize I shouldn't do password validation with javascript. This is just a test page.
Nov 8 '07 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 173

What version of IE is this not working in? I have tried in 5.5, 6 and 7 and they all seem to work. Having said that are a couple of things that I would change with the HTML, if using XHTML then all attributes need to be surrounded by quotes (this is also good practice to make the code more readable) so then the code would be:
Expand|Select|Wrap|Line Numbers
  1. <a href='javascript:validate("page2.htm")'>Admin</a>
It is also customary that if one branch of an if statement is multiline then all of them should be, again this is will probably not affect anything but is good practice.

If you are still having issues then try validating the document and making sure that you DOCTYPE is correct.
Nov 8 '07 #2

P: 219
I'm a moron. I didn't have the script referenced correctly in the <head> section.
Nov 8 '07 #3

Post your reply

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