Author |
Message |
djw2
Regular


Joined: Sep 19, 2003
Posts: 95
Location: St. Louis, MO
|
Posted:
Sun Jan 04, 2004 9:55 am |
|
Hey Raven and the gang,
I want to open a couple html pages in a popup window from a page in the content module but I'd like the option of using a popup from anywhere so can I do a global popup script?
I read the script needs to be in includes/javascript.php but when I looked at that file it obviously wasn't standard javascript.
Here's the copyright script from that file.
Code:global $module, $name;
if ($module == 1 AND file_exists("modules/$name/copyright.php")) {
echo "<script type=\"text/javascript\">\n";
echo "<!--\n";
echo "function openwindow(){\n";
echo " window.open (\"modules/$name/copyright.php\",\"Copyright\",\"toolbar=no,location=no,
directories=no,status=no,scrollbars=yes,resizable=no,
copyhistory=no,width=400,height=200\");\n";
echo "}\n";
echo "//-->\n";
echo "</SCRIPT>\n\n";
}
|
This is essentially what I want but what script would I add to the file?
Does every window need it's own script listed here?
How then do I call that script from a link tag?
Thanks.
Dan |
|
|
|
 |
Raven
Site Admin/Owner

Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Sun Jan 04, 2004 10:03 am |
|
Actually, it is standard javascript. PHP echos the code to the browser.
Just write your own popup function and place it in includes/my_header.php or add it as a function in mainfile.php. Then just call the function as needed in your page. Or, you could also add a target="" attribute to the anchor tag (link) in your pages. |
|
|
|
 |
djw2

|
Posted:
Sun Jan 04, 2004 10:16 am |
|
Okay... so I add this script to includes/my_header.php
Code:echo "<script language="JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script> ";
|
But when I call the script with this link.
Code:<a href="javascript:MM_openBrWindow('issues.html','issues','scrollbars=yes,width=800,height=600')">issues</a>
|
I get this message.
Quote: | The html tags you attempted to use are not allowed |
What am I doing wrong?
Thanks again.
Dan |
|
|
|
 |
Raven

|
Posted:
Sun Jan 04, 2004 10:27 am |
|
Could be a couple of things. When you first open your main web page and do a browse source, do you see your javascript function towards the top of the page? If not, then you have to either echo it to the browser or use the HEREDOC syntax. Place this code in my_header.php before the closing ?> tagCode:$js = <<<_JS_
<script language="JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>
_JS_;
echo $js;
|
|
|
|
|
 |
djw2

|
Posted:
Sun Jan 04, 2004 10:32 am |
|
Okay I'll try that, but what about the whole "The html tags you attempted to use are not allowed" thing.
What do I need to do to call the script? |
|
|
|
 |
Raven

|
Posted:
Sun Jan 04, 2004 10:35 am |
|
Just try my code and see if that resolves it. |
|
|
|
 |
djw2

|
Posted:
Sun Jan 04, 2004 11:03 am |
|
Okay, with the last script you gave me I get
Quote: | Parse error: parse error in /home/dwhelan/public_html/imwithdennis/includes/my_header.php on line 35 |
Line 35 of my_header.php has
Oops. |
|
|
|
 |
Raven

|
Posted:
Sun Jan 04, 2004 11:06 am |
|
It works fine here, so it's your syntax. That code must be between the php tags, as inCode:<?
$js = <<<_JS_
<script language="JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>
_JS_;
echo $js;
?>
|
|
|
|
|
 |
djw2

|
Posted:
Sun Jan 04, 2004 11:08 am |
|
BTW
This script is already in the my_header.php
Code:echo "<script language=\"JavaScript\">
<!--
function winOpen(URL) {
window.open(
URL,
'popup',
'width=800,height=600,resizable=1,'
);
}
// -->
</script> ";
|
Why could I just call that one?
Although, it's resizable and I don't want that... and I need scrollbars as needed... but that's a popup script right? Is that the copyright script? |
|
|
|
 |
djw2

|
Posted:
Sun Jan 04, 2004 11:10 am |
|
It was inside the php tags.
Just like this
Code:<?php
/************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* Copyright (c) 2002 by Francisco Burzi */
/* http://phpnuke.org */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
/*
This file is to customize whatever stuff you need to include in your site
when the header loads. This can be used for third party banners, custom
javascript, popup windows, etc. With this file you don't need to edit
system code each time you upgrade to a new version. Just remember, in case
you add code here to not overwrite this file when updating!
Whatever you put here will be between <head> and </head> tags.
*/
echo "<script language=\"JavaScript\">
<!--
function winOpen(URL) {
window.open(
URL,
'popup',
'width=800,height=600,resizable=1,'
);
}
// -->
</script> ";
$js = <<<_JS_
<script language="JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
//-->
</script>
_JS_;
echo $js;
?>
|
$js = <<<_JS_ is line 35. |
|
|
|
 |
Raven

|
Posted:
Sun Jan 04, 2004 11:16 am |
|
Remove your original echo statement and just leave my code. Yours is syntactically wrong. |
|
|
|
 |
djw2

|
Posted:
Sun Jan 04, 2004 11:19 am |
|
That isn't mine... that's there already.
I don't know what it is but I'm afraid if I remove it then something isn't going to work.
 |
|
|
|
 |
djw2

|
Posted:
Sun Jan 04, 2004 11:23 am |
|
I just opened the original my_header.php from the core files and the script isn't there so I don't know what it is.
I have never edited this file before today... how strange. |
|
|
|
 |
djw2

|
Posted:
Sun Jan 04, 2004 11:27 am |
|
I'm sorry. I hadn't "edited" the file but I did overwrite it.
That's the NukeTV popup script. I could just call it couldn't I? |
|
|
|
 |
Raven

|
Posted:
Sun Jan 04, 2004 11:33 am |
|
If it's works then try it. |
|
|
|
 |
djw2

|
Posted:
Sun Jan 04, 2004 11:48 am |
|
It does work in NukeTV.
Here's how they call it
Code:<a href=\"#\" onClick=\"winOpen('modules.php?name=$ModName&file=cadena&cadena=".$ligne["id"]."')\">".$ligne["cadena"]."</a>
|
But they’re calling it from NukeTV/index.php.
I need to call it from a link on a content page so how does that translate to a html link?
Here the way I was trying it.
Code:<a href="javascript:winOpen('issues.html','issues','scrollbars=yes,width=800,height=600')">issues</a>
|
But I had the html not allowed error and this code is specifying the window size in the script.
Code:echo "<script language=\"JavaScript\">
<!--
function winOpen(URL) {
window.open(
URL,
'popup',
'width=800,height=600,resizable=1,'
);
}
// -->
</script> ";
|
I'm not going to be able to call the dimensions too.
Do you know how my link should look?
Thanks for all your help. |
|
|
|
 |
Raven

|
Posted:
Sun Jan 04, 2004 12:08 pm |
|
Code:<a href="#" onClick="winOpen('issues.html','issues','scrollbars=yes,width=800,height=600')">issues</a>
|
|
|
|
|
 |
djw2

|
Posted:
Sun Jan 04, 2004 12:16 pm |
|
That was it!
Thanks Raven, you ROCK!
PEACE!
Dan |
|
|
|
 |
|