This topic is locked

How to create hyperlink that opens popup window

3/17/2009 5:18:28 AM
PHPRunner General questions
A
Astrid author

Creating hyperlinks that open in blank window works fine. But I would like to create a hyperlink that opens the file in a popup window. In my old HTML site I used this code:

<href="/startlijsten/w0104sl1.htm" onclick="window.open('/startlijsten/w0104sl1.htm','startlijst','scrollbars=yes,width=600,height=600,left='+(screen.availWidth/2-300)+',top='+(screen.availHeight/2-300)+'');return false;">S1</a>



Where w0104sl1.htm stands for the text that is now stored in the database in the field with name S1.
I've tried several solutions from the forum, but none is working.

J
Jane 3/17/2009

Hi,
use custom format on the "View as" settings dialog on the Visual Editortab.

Here is a sample:

$value = "<a href=\"/".$value."\" onclick=\"window.open('/startlijsten/w0104sl1.htm','startlijst','scrollbars=yes,width=600,height=600,left='+(screen.availWidth/2-300)+',top='+(screen.availHeight/2-300)+'');return false;\">S1</a>";

A
Astrid author 3/17/2009

Thx Jane,

Made some minor changes, but it works partially. This code makes pop up appear with right .htm file

$value = "<a href=\"/".$value."\" onclick=\"window.open('../startlijsten/$value.','startlijst','scrollbars=yes,width=600,height=600,left='+(screen.availWidth/2-300)+',top='+(screen.availHeight/2-300)+'');return false;\">S1</a>";


But not all fields have values and because of the fixed text "S1" the text S1 appears in every record.

return false;\">S1</a>"


Tried to change it into

return false;\">$value</a>"



But then it returns the full filename, which is not very nice.
Surely there must be another way to show only valid links i.e. using the name of de column header?. Can you help me once again please?

J
Jane 3/17/2009

Hi,
check this code:

$value = "<a href=\"/".$value."\" onclick=\"window.open('../startlijsten/$value.','startlijst','scrollbars=yes,width=600,height=600,left='+(screen.availWidth/2-300)+',top='+(screen.availHeight/2-300)+'');return false;\">".$value."</a>";

A
Astrid author 3/17/2009

Hi Jane,

No difference. Still showing complete filename.

J
Jane 3/18/2009

Hi,
you can check field value before:

if ($value)

$value = "<a href=\"/".$value."\" onclick=\"window.open('../startlijsten/$value.','startlijst','scrollbars=yes,width=600,height=600,left='+(screen.availWidth/2-300)+',top='+(screen.availHeight/2-300)+'');return false;\">S1</a>";

A
Astrid author 3/18/2009

Hi Jane,

Super! Thanx. Tried about every solution I've found in this forum and who would have thought it to be so easy.