How to get a popup window using ajax?
Hi,
I am working with php website.
I am not very familiar with ajax but I want a popup window. I want to know is how to get a popup window using ajax? If anyone have the code or please let me guide in a proper direction it will be a great help.
I want to use popup window with ajax because
Much quicker to load as it can preload contents.
The display is really dynamic.
Thanks in advance.
Re: How to get a popup window using ajax?
Hey I think this is what you are looking for.
This taglib lets you define a hyperlink that popups some window with your own HTML/JSP code.
Code:
<script language="JavaScript" src="cjajax.js"></script>
<%@ taglib uri="taglib.tld" prefix="ap" %>
What does
<ap:apopup onMouse="true" url="/servlet/MVC">it mean?</ap:apopup>
<br>Just click on the link or move your mouse over it.
Tag lets you request data from server side (attribute url) and display them in the popup window. Attribute urlFunction lets you define a JavaScript function that will construct URL for the request in dynamic.
Re: How to get a popup window using ajax?
Here's the code I recommend:
Code:
var newWin = null;
function popUp(strURL, strType, strHeight, strWidth) {
if (newWin != null && !newWin.closed)
newWin.close();
var strOptions="";
if (strType=="console")
strOptions="resizable,height="+
strHeight+",width="+strWidth;
if (strType=="fixed")
strOptions="status,height="+
strHeight+",width="+strWidth;
if (strType=="elastic")
strOptions="toolbar,menubar,scrollbars,"+
"resizable,location,height="+
strHeight+",width="+strWidth;
newWin = window.open(strURL, 'newWin', strOptions);
newWin.focus();
}
To call the function you would use the following code:
Code:
<a href="my-pop-up-window.htm"
onclick="popUp(this.href,'console',400,200);return false;"
target="_blank">This is my link</a>
You can put a condition to close the popup too.