troubleshooting Question

Open link in Same Window using Javascript in PHP

Avatar of JParra72
JParra72 asked on
JavaScriptPHPScripting Languages
7 Comments2 Solutions412 ViewsLast Modified:
Hello,  
the script below currently opens a link in another window after a user clicks on a submit button.  I would like for the link to open in the same window where the user clicked on submit.

The portion of the php code looks like this:

if ($resp->is_valid) {
    {
  echo '<script language="javascript">window.open("join_form", "openContract");</script>';
  echo '<a href="join_form" target="_parent">Click here if not redirected automatically.</a>';
  }

Thanks all
script language="javascript" type="text/javascript">
function openContract(theurl)
{
 // set the width and height
 var the_width=( screen.width - 25 );
 var the_height=( screen.height - 100 );
 
 // set window position
 var from_top=0;
 var from_left=0;
 
 // set other attributes
 var has_toolbar='yes';
 var has_location='no';
 var has_directories='yes';
 var has_status='no';
 var has_menubar='yes';
 var has_scrollbars='yes';
 var is_resizable='yes';
 
 // attributes put together
 var the_atts='width='+the_width+',height='+the_height+',top='+from_top+',screenY='+from_top+',left='+from_left+',screenX='+from_left;
 the_atts+=',toolbar='+has_toolbar+',location='+has_location+',directories='+has_directories+',status='+has_status;
 the_atts+=',menubar='+has_menubar+',scrollbars='+has_scrollbars+',resizable='+is_resizable;
 
 // open window
 window.open(theurl,'',the_atts);
}
</script>
ASKER CERTIFIED SOLUTION
themrrobert

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros