Jump to content

Recommended Posts

To open the popup you could pass a variable (via GET/POST [side note: make sure if you use either of those to check to make sure the user has permissions to edit that comment, because they can be easily faked] or a server-side session) when opening the page, whether via target='_blank' for new page, or using javascript's window open method.

var newWindow;
function popwindow(url) {
if (parseInt(navigator.appVersion)>3) {
	if (navigator.appName=="Netscape") {
		winW = window.innerWidth;
		winH = window.innerHeight;
	}
	if (navigator.appName.indexOf("Microsoft")!=-1) {
		winW = document.body.offsetWidth;
		winH = document.body.offsetHeight;
	}
}
var scrollbars = ",scrollbars=0,";
if(winW<(winWidth+5) || winH<(winHeight+5)) {
	//alert("You will have scrollbars. Your inner height and width are as following: \n"+winW+" by "+winH);
	scrollbars = ",scrollbars=1,";
	winWidth = 800;
	winHeight = 600;
}
var data = 'height='+winHeight+',width='+winWidth+scrollbars+'location=0,status=0,directories=0,toolbar=0,menubar=0,resizable=1';
newWindow=window.open(url,'name',data);
if (window.focus) {newWindow.focus()}
}

<a href="popup.php?id=6" onclick="popwindow('popup.php?id=6'); return false;" target="_blank">popup</a>

On the popup page, have it pull data from the database - and auto populate the fields. Then use an onClick or form action to submit the form.

 

If you know your users will have javascript enabled - using the window.open and onClick would be the fastest, and nicest way. However, being able to fall back onto the target='_blank' and form action is 100% needed if you are not sure if your users have javascript enabled.

 

Hopefully thats what you're looking for

Link to comment
https://forums.phpfreaks.com/topic/138251-ajax-popup/#findComment-722917
Share on other sites

  • 2 weeks later...
  • 1 month later...

EDIT:

 

I have noticed that this does work in internet explorer 7 but not in firefox? What would I have to change to get it to work in firefox? This is the contents of my ajax.js file:

 

<script type="text/javascript">

<!--

 

//Create a boolean variable to check for a valid Internet Explorer instance.

var xmlhttp = false;

 

//Check if we are using IE.

try {

//If the Javascript version is greater than 5.

xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

 

} catch (e) {

//If not, then use the older active x object.

try {

//If we are using Internet Explorer.

xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

 

} catch (E) {

//Else we must be using a non-IE browser.

xmlhttp = false;

}

}

 

//If we are using a non-IE browser, create a javascript instance of the object.

if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {

xmlhttp = new XMLHttpRequest();

 

}

 

function makerequest(serverPage, objID) {

 

var obj = document.getElementById(objID);

xmlhttp.open("GET", serverPage);

xmlhttp.onreadystatechange = function() {

if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {

obj.innerHTML = xmlhttp.responseText;

}

}

xmlhttp.send(null);

}

 

var newWindow;

function popwindow(url) {

  if (parseInt(navigator.appVersion)>3) {

      if (navigator.appName=="Netscape") {

        winW = window.innerWidth;

        winH = window.innerHeight;

      }

      if (navigator.appName.indexOf("Microsoft")!=-1) {

        winW = document.body.offsetWidth;

        winH = document.body.offsetHeight;

      }

  }

  var scrollbars = ",scrollbars=0,";

  if(winW<(winWidth+5) || winH<(winHeight+5)) {

      //alert("You will have scrollbars. Your inner height and width are as following: \n"+winW+" by "+winH);

      scrollbars = ",scrollbars=1,";

      winWidth = 300;

      winHeight = 200;

  }

  var data = 'height='+winHeight+',width='+winWidth+scrollbars+'location=0,status=0,directories=0,toolbar=0,menubar=0,resizable=1';

  newWindow=window.open(url,'name',data);

  if (window.focus) {newWindow.focus()}

}

 

//-->

</script>

Link to comment
https://forums.phpfreaks.com/topic/138251-ajax-popup/#findComment-775484
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.