Click to See Complete Forum and Search --> : Including Javascript in PHP


trevzilla
04-30-2008, 03:21 PM
I have a PHP page with a lot of links on it. However if possible I would like to have a pop up window of the link appear if the user doesn't have pop ups blocked. But if the user does block pop ups, I would like the link to open in the main window. I'm pretty sure this is javascript code. (If I can use PHP to do this, I'd much rather do that) But with that said, does any one know how to do this?

Thanks!

SyCo
04-30-2008, 04:46 PM
This is a method to open a window if javascript is turned off. Add a normal link with a targeted new window, use javascript to return it false. In the same onclick event call a jS function to open your window.

<HTML>
<HEAD>
<script type="text/javascript">
<!--
function openwindow(){
window.open('http://google.com','mywin',
'left=20,top=20,width=500,height=500,toolbar=1,resizable=0');
}
//-->
</script>
</HEAD>

<BODY>

<a href="http://google.com" target="NewWindow" onClick="openwindow();return false;"> Visit google</a>

</BODY>
</HTML>

I have pop blocker turn on and it opens the new window. Popup blockers are supposed to block unrequested windows, an onclick is a requested event so should be OK.

MrCoder
05-01-2008, 05:33 AM
You *may* find ThickBox useful if you are only displaying text / images in your popup, thou you could use an iFrame in it I believe.

http://jquery.com/demo/thickbox/