problem with window.open() and document.form.submit()

Discussion in 'JavaScript' started by kfir, Oct 15, 2007.

  1. #1
    Hello,
    Well the first function that I would like to get some help about is this one:
    
    var popup;
    function openPopUp(mid,title){
    	var location	= "blocks/watch.php?mid="+mid;
    	var title		= "iLTv - "+title;
    	var propreties	= "height=400px";
    	propreties	   += ",width=600px";
    	propreties	   += ",menubar=no";
    	propreties	   += ",location=yes";
    	propreties	   += ",resizable=no";
    	propreties	   += ",scrollbars=no";
    	propreties	   += ",status=no";
    	propreties	   += ",titlebar=no";
    	popup = window.open(location,title,propreties);
    }
    
    PHP:
    And this is how I activate the function
    
    <a href="javascript:openPopUp('1','ruby')">
    
    HTML:
    Now the problem is that this function doesn't work on IE for some reason... (On FF and OPERA it works perfectly fine so what's the problem here?)

    Now another problem that I've encountered is about submitting forms (this time the function works fine in IE but doesn't work on FF and OPERA)
    
    function check(){
    	var check	 = true;
    	var user	 = document.getElementById('user');
    	var userText = document.getElementById('userText');
    	var pass	 = document.getElementById('pass');
    	var passText = document.getElementById('passText');
    	userText.style.color="#838383";
    	passText.style.color="#838383";
    	if(user.value==""){
    		userText.style.color="#FF0000";
    		check = false;
    	}
    	if(pass.value==""){
    		passText.style.color="#FF0000";
    		check = false;
    	}
    	if(check)document.loginForm.submit();
    }
    
    PHP:
    And the form that goes with this function is
    
    <form name="loginForm" action="" method="post">
           	<input type="hidden" name="tmp" value="login" />
    		<table cellpadding="0" cellspacing="0">
    			<tr>
    				<td id="userText">Username:</td>
    				<td>
    				<input type="text" name="user" maxlength="15" id="name" />
    			</td>
    		</tr>
    		<tr>
    			<td id="passText">Password:</td>
    			<td>
    				<input type="password" name="pass" id="pass" />
    			</td>
    		</tr>
    		<tr>
    			<td colspan="2" align="left">
    				<button onclick="check()">
    					Send
    				</button>
    			</td>
    		</tr>
    	</table>
    </form>
    
    HTML:
    Now here the problem is that in FF and OPERA the form will be submitted at any case. What's the problem here and how can I solve it?

    Thanks in advance for the help
     
    kfir, Oct 15, 2007 IP
  2. Logic Ali

    Logic Ali Well-Known Member

    Messages:
    170
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    108
    #2
    I.E. won't allow spaces or dashes in the title parameter.
    There is no need to include javascript: in any script. Pass it on.
    <a href="#" onclick="openPopUp('1','ruby');return false">
    Code (markup):
    The <button> tag has limited support - use a submit-type <input>. The check function should not call the submit method, it should return the value of the check variable (which should ideally not have the same name as any function).

    <form .......... onsubmit="return check()">
    .
    .
     <input type='submit' value='Send'>
    </form>
    
    Code (markup):
     
    Logic Ali, Oct 20, 2007 IP