Create popup inside function

What my code is trying to do is add a new group if not already created, well it works fine now, but I also want to open a new popup as soon as the group is created, prompting the user to invite others, but it seems to me that mine work doesn't work, any idea on how to make it work?

thanks

<html>
<head>
<script type="text/javascript">

function addGroup()
{
  x=document.getElementById("group").getElementsByTagName("p");
  groups=document.getElementById("groupName");
  var j=0,i=0;  


  if   (groups.value=="")
  {
      alert('must create one group');
  }



   for (i=0;i<x.length;i++)
   { 
     if (x[i].innerHTML == groups.value)
     {
         alert('the group name is already created');
         return false;
     }  
   }



   if (!j)
   {
      var newNode=document.createElement('p');
      var newString=document.createTextNode(groups.value); 
      newNode.appendChild(newString);
      x[0].parentNode.appendChild(newNode);
      newWindow();
   }
}

function newWindow()
{
    window.open('http://invite Others.html','invite  
                         others','width=400,height=200,toolbar=yes,                             
      location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes,
                             resizable=yes');
      winObj.focus();
}
</script>

</head>
<body>

<div id="group">
<ul>
   <p>Group03</p>
   <p>Group02</p>
</ul>
</div>

<p><input type="text" id="groupName" size="84" maxlength="84" value=""/></p>
<p><input type="button" value="create" onclick="addGroup()" /></p>
<p><input type="button" value="remove" onclick="removeNo()"/> </p>
</body>
</html>

      

0


a source to share


1 answer


Your problem looks like window.open (). http: // invite others.html is not a valid web address, so it returns an error.

Firebug returned this when I click the create button.



uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMJSWindow.open]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://localhost/ :: newWindow :: line 43" data: no]

      

However, if you use http: // localhost / invite the others.html file works fine. So just add your hostname after htttp: // and you should be good to go.

+1


a source







All Articles