Log in

View Full Version : PopUp in PHP



Diversions
03-02-2008, 06:59 PM
I am in the process of building an e-commerce site in PHP (not my work) What I want to do is have certain pages such as About Us and FAQ pop up in a small unadorned window with a "close window" control and nothing more except it would be nice to have a specific border color along the top bar.

My question is this:- Of all the scripts written in Dynamic Drive...which one am would I be best to use given my limited expertise in PHP development.

Thanks for your help

Anexxion
03-02-2008, 08:48 PM
heres a script you could use:



<SCRIPT LANGUAGE="JavaScript">

function popup(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=1280,height=1024');");
}

</script>

put that in your head tags,
then in the body tags put:


<form>
<input type="WHATEVER INPUT TYPE" value="Open the Popup Window" onClick="javascript:popup('LINK GOES HERE')">
</form>

also in the bolded part of the previous form code, if you want to make it an image, put
<input type="image" ... followed by src="source.png/gif/whatever"

and you will have your popup, also, heres a live preview i setup for you :D

www.voi-design.com/test.html

^^my site, not open for awhile, im a graphics designer.

im going to look into setting the size and form placment on the screen for it, hope i helped?

PHP:


<a href="javascript: window.open('index.html', 'window_name', 'width = 250, height = 50');">INDEX TEST</a>

way simpler, but there is one thing that is wierd about it, go to www.voi-design.com/test.html and click "INDEX TEST", it changes the page....












EDIT: SCRAP ALL THAT, just use this



<form>
<input type="submit" value="Popup window" onClick="javascript: window.open('LINK GOES HERE', 'window_name', 'width = 250, height = 50');">
</form>















edit 2: -final solution-

1. in your head tags, put:


<SCRIPT TYPE="text/javascript">
<!--
function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
href=mylink;
else
href=mylink.href;
window.open(href, windowname, 'width=400,height=235,scrollbars=yes');
return false;
}
//-->
</SCRIPT>

edit the bolded red text accordingly

2: in the link that you want to initiate the popup, put:


<A HREF="LINK" onClick="return popup(this, 'notes')">WHATEVER</A>

edit the bolded red accordingly and there you go!

i set another live preview up at www.voi-design.com
click on "Order a design "HERE""

:D

this also helped me alot too, thanks! (sorry for the huge long post)

Diversions
03-03-2008, 08:05 PM
Thanks for your help Anexxion. I will be working with these codes over the next few days to see how it all comes together.

Anexxion
03-03-2008, 10:14 PM
yeah no problem, i myself didnt know how to do it, just use the "final solution", i have yet to find out how to place it with javascript on the page, then dim everything else but the document