SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    firefox stopping on a popupwindow script

    i got one script which is working fine with IE, Opera, Safari but when i try to run it on FF it just hangs up and i have installed the Firebug to debug it and i found one error like:

    popup_win.formD has no properties
    [Break on this error] popup_win.formD.submit()

    i have the following code with me:

    HTML Code:
    function confirm_popup(user,id,display,action,searchtxt){
      popup_win = window.open('c.cfm', '', 'toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,width=300,height=180,scrollbars=0');
      popup_win.document.write("<HTML>");
      popup_win.document.write("<BODY>");
    
      popup_win.document.write("  <FORM NAME='formD' ACTION='c.cfm' METHOD='post'>  ");
      popup_win.document.write("  <INPUT TYPE=hidden NAME='user' VALUE="+user+">          "); 
      popup_win.document.write("  <INPUT TYPE=hidden NAME='id' VALUE="+id+">              ");
      popup_win.document.write("  <INPUT TYPE=hidden NAME='display' VALUE='"+display+"'>  ");
      popup_win.document.write("  <INPUT TYPE=hidden NAME='action' VALUE='"+action+"'>    ");
      popup_win.document.write("  <INPUT TYPE=hidden NAME='searchtxt' VALUE='"+searchtxt+"'> ");
      popup_win.document.write("  </FORM>");
    
      popup_win.document.write("</BODY>");
      popup_win.document.write("</HTML>");
      popup_win.focus();
      popup_win.formD.submit();
    
      popup_win.name="popup";
      self.name="main";
    }
    
    
    
    
    

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Do you have the popup blocker active in Firefox?

    Maybe give the form an id as well as a name, and getElementById() the form to submit it?

    Alternatively, use XMLHTTP to submit the data without even needing to open a popup? (Here's an example of how I do it) ...

    Code JavaScript:
    function updateSelections (cid, pid, tcb) {
    	var xmlHttp;
    	var resp = '';
    	try {
    		// Firefox, Opera 8.0+, Safari
    		xmlHttp = new XMLHttpRequest();
    	}
    	catch (e) {
    		// Internet Explorer
    		try {
    			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    		}
    		catch (e) {
    			try {
    				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    			}
    			catch (e) {
    				alert ('Your browser does not handle the photo selection process');
    				return false;
    			}
    		}
    	}
    	xmlHttp.onreadystatechange = function() {
    		if (xmlHttp.readyState == 4) {
    			resp = xmlHttp.responseText;
    			if (resp != 'OK') {
    				alert ('There was a problem recording your photo selection request.');
    			}
    		}
    	}
     
    	// Send the info to the PHP handler page
    	var data = 'updatephototemptable.php?cid=' + cid + '&pid=' + pid + '&tcb=' + tcb;
     
    	xmlHttp.open ("GET",data,true);
    	xmlHttp.send (null);
    }
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe give the form an id as well as a name, and getElementById() the form to submit it?
    i cannot change the stufff buddy as it is being used and they do not want change this way, i added the id attribute to the form tag and changed the form id="formD" but still it stops at the same error.

    Thanks

  4. #4
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    window.open returns null if the dialog failed for some reason (popup blocker). You can add a null check on the popup_win before you start writing to it.

  5. #5
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how can i do thta?

    plz i am new in javascript

  6. #6
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    popup_win = window.open('c.cfm', '', 'toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,width=300,height=180,scrollbars=0');
    
    if (popup_win != null) {
        // write to the popup, since it exists
    } else {
        alert("popup did not open!");
    }

  7. #7
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    now it si showing me this eroor but also popup is not opening..

    popup_win is not defined
    confirm_popup(0, 1, "System Analyst", "deljob", "")popup.js (line 2)
    [Break on this error] if (popup_win != null) {

  8. #8
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry for that above code i just placed the IF tag just above the popup_win,

    i modified it but it still stopping at the same error and popup is coming up and it is not showng me any alert box, i changed the code as:

    function confirm_popup(user,id,display,action,searchtxt){
    popup_win = window.open('confirm.cfm', '', 'toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,width=300,height=180,scrollbars=0');
    if (popup_win != null)
    {
    popup_win.document.write("<HTML>");
    popup_win.document.write("<BODY>");

    popup_win.document.write(" <FORM NAME='formD' ACTION='confirm.cfm' METHOD='post' id='formD'> ");
    popup_win.document.write(" <INPUT TYPE=hidden NAME='user' VALUE="+user+"> ");
    popup_win.document.write(" <INPUT TYPE=hidden NAME='id' VALUE="+id+"> ");
    popup_win.document.write(" <INPUT TYPE=hidden NAME='display' VALUE='"+display+"'> ");
    popup_win.document.write(" <INPUT TYPE=hidden NAME='action' VALUE='"+action+"'> ");
    popup_win.document.write(" <INPUT TYPE=hidden NAME='searchtxt' VALUE='"+searchtxt+"'> ");
    popup_win.document.write(" </FORM>");

    popup_win.document.write("</BODY>");
    popup_win.document.write("</HTML>");
    popup_win.focus();
    popup_win.formD.submit();

    popup_win.name="popup";
    self.name="main";
    }
    else
    {
    alert("popup did not open!");
    }
    }

  9. #9
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this (notice the changes in bold):

    Code:
    function confirm_popup(user,id,display,action,searchtxt){
      popup_win = window.open('confirm.cfm', '', 'toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,width=300,height=180,scrollbars=0');
      if (popup_win != null) {
      popup_win.document.open();
      popup_win.document.write("<HTML>");
      popup_win.document.write("<BODY>");
    
      popup_win.document.write("  <FORM NAME='formD' ACTION='confirm.cfm' METHOD='post' id='formD'>  ");
      popup_win.document.write("  <INPUT TYPE=hidden NAME='user' VALUE="+user+">          "); 
      popup_win.document.write("  <INPUT TYPE=hidden NAME='id' VALUE="+id+">              ");
      popup_win.document.write("  <INPUT TYPE=hidden NAME='display' VALUE='"+display+"'>  ");
      popup_win.document.write("  <INPUT TYPE=hidden NAME='action' VALUE='"+action+"'>    ");
      popup_win.document.write("  <INPUT TYPE=hidden NAME='searchtxt' VALUE='"+searchtxt+"'> ");
      popup_win.document.write("  </FORM>");
    
      popup_win.document.write("</BODY>");
      popup_win.document.write("</HTML>");
      popup_win.document.close();
      popup_win.focus();
      popup_win.formD.submit();
    
      popup_win.name="popup";
      self.name="main";
      }
    	else 
      {
        alert("popup did not open!");
      }
      }

  10. #10
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i get this err now, popup opens up and it shows nothing, the status bar gets completed and give this error:

    popup_win.formD has no properties
    confirm_popup(0, 2, "network engineer", "deljob", "")popup.js (line 21)
    [Break on this error] popup_win.formD.submit();
    popup.js (line 21)
    popup_win.formD has no properties
    confirm_popup(0, 2, "network engineer", "deljob", "")popup.js (line 21)
    [Break on this error] popup_win.formD.submit();

  11. #11
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That is not the way to access the form. Use either document.geElementById or document.forms to access the form.

    Other things, there is no need to do this
    Code:
    popup_win.name="popup";
    You can set the name when calling the window.open method.

    Also, there is no need for the following:
    Code:
    toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0,scrollbars=0
    These are the default values and don't need to be set.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •