Forum Moderators: coopster

Message Too Old, No Replies

Javascript in PHP

         

vasquezmi

10:06 pm on Dec 23, 2003 (gmt 0)

10+ Year Member



I have a PN block that displays a list of recent articles and provides the visitor with a link to the Topic or specific article. <snip> At the bottom of the screen you will see a section called This Week.... This is the part I am referring to.

Currently, the user will click on the link title or the Go image and it will take the user to a new page. I would like when the user clicks on the image that it opens a popup window. Here is the code as it shows for the Go link.


$readmoreimg = _LEXREADMORE;
if (file_exists("images/lexe_news_topics/".$language."-go.gif")) {
$readmoreimg = "<img src=\"images/lexe_news_topics/$language-go.gif\">";}
elseif (file_exists("images/lexe_news_topics/go.gif")) {}

if (strlen($hometext) > $homemlength) {
$hometext = substr($hometext,0,$homelength);
$topic = $topic;
$hometext .= "... "."<a href=\"modules.php?op=modload&name=News&file=article&sid=$sid&amp;topic=$topic\"><em>" .$readmoreimg."</em></a>";
}

I am not sure how to recode the href to allow ONCLICK to open.window.

Help,

V

[edited by: jatar_k at 10:22 pm (utc) on Dec. 23, 2003]
[edit reason] no personal urls thanks [/edit]

Elijah

10:15 pm on Dec 23, 2003 (gmt 0)

10+ Year Member



Try adding target="_blank" to your link
For example:

$hometext .= "... "."<a href=\"modules.php?op=modload&name=News&file=article&sid=$sid&amp;topic=$topic\" target=\"_blank\"><em>".$readmoreimg."</em></a>";

Hope this helps,

Elijah

[edited by: jatar_k at 10:23 pm (utc) on Dec. 23, 2003]
[edit reason] thanks [/edit]

vasquezmi

10:38 pm on Dec 23, 2003 (gmt 0)

10+ Year Member



That just opens a new window for the site. Not a small popup window.

I think that I am going to need the link to open a specific file as the popup. Suggestions on how to code that?

V

louponne

8:51 am on Dec 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Simplest is to separate the javascript from the php:

<script language="JavaScript" type="text/javascript">
<!--
function popup(url) {
newin = window.open(url, "nameofpopup", 'width=580,height=540,noresize,scrollbars');
}

//-->
</script>

echo "<a href=\"javascript:popup('modules.php?op=modload&name=News&file=article&sid=$sid&topic=$topic')\">linktext</a>";

If the url is always going to include certain parts, you can hardcode that into the javascript to simplify the url in your php.

(I also removed the &amp; from your query string - I'll bet that's an error)