PDA

View Full Version : Javascript not working properly in Joomla



erpicio
Oct 12th, 2010, 09:12 PM
Hello,
i am a total newbie, so forgive me :)

i have the following problem: a Joomla Gallery uses a javascript to show fullsize images.

but when the popup windows comes out, it doesn't have any properties (page title, url about:blank, blank background etc)

here is a screenshot: http://img72.imageshack.us/img72/5301/esempiopopup.jpg

I think the following to be the code that calls the popup: what's wrong?

NOTE I already had to remove some "spaces" from the code because the Joomla SEF was changing the urls forbidding the right execution of everything, maybe it's something like that... dunno :cry:


$htmltext2 .= "<script language=\"JavaScript\">";



$htmltext2 .= "function pgpopup(pgimagefile,pgimagetitle,pgimagedescription) {\n";

$htmltext2 .= "var newWindow = window.open(\"\",\"newWindow\",\"height=" . ($tabparams["pgmaxheight"]+$dparm[2]) . ",width=" . ($tabparams["pgmaxwidth"]+$dparm[3]) . ",resizable=yes, scrollbars=yes, toolbar=no " . "\" );\n";

$htmltext2 .= "var imageurl = \"<img src= \"+ pgimagefile + \">\";\n";

$htmltext2 .= "newWindow.document.open();";

$htmltext2 .= "newWindow.document.writeln(\"<div align='center' >\");\n";

$htmltext2 .= "newWindow.document.writeln(\"<title>Profile Gallery Image: \"+ pgimagetitle + \"</title>\");\n";

$htmltext2 .= "newWindow.document.writeln(imageurl);\n";

$htmltext2 .= "newWindow.document.writeln(\"<br />\");";

$htmltext2 .= "newWindow.document.writeln(pgimagedescription);\n";

$htmltext2 .= "newWindow.document.writeln(\"</div>\");\n";

$htmltext2 .= "newWindow.document.close();\n";

$htmltext2 .= "}\n";

$htmltext2 .= "</script>";

break;

anyone can help?

thanks!

DaveyErwin
Oct 12th, 2010, 09:41 PM
$htmltext2 .= "newWindow.document.writeln(\"<div align='center' >\");\n";

$htmltext2 .= "newWindow.document.writeln(\"<title>Profile Gallery Image: \"+ pgimagetitle + \"</title>\");\n";


i always thought tittle had to be in head
not in a div but it works that way for me ?

$htmltext2 .= "</script>";
I do it like this
$htmltext2 .= "</scr"+"ipt>";

is that javascript ??

erpicio
Oct 13th, 2010, 01:34 AM
:(

it says:

$htmltext2 .= "<script language=\"JavaScript\">";
so it should be...

Old Pedant
Oct 13th, 2010, 02:18 AM
That's not a but and not an error.

The author did it *INTENTIONALLY* that way.

You can easily change it.



$htmltext2 .= "var newWindow = window.open(\"\",\"newWindow\",\"height="
. $tabparams["pgmaxheight"]+$dparm[2]) . ",width="
. ($tabparams["pgmaxwidth"]+$dparm[3])
. ",resizable=yes, scrollbars=yes, toolbar=no " . "\" );\n";

that is setting the height and width, making the window resizable and scrollable, and removing the toolbar.

I you want a toolbar, change "toolbar=no" to "toolbar=yes". If you want other window characteristics, just specify them in that code.

Old Pedant
Oct 13th, 2010, 02:26 AM
i always thought tittle [sic] had to be in head
not in a div but it works that way for me ?

In MSIE, yes. But see his Chrome screen shot. It doesn't work there.

Man that is utterly crap code, isn't it?

erpicio
Oct 13th, 2010, 02:32 AM
I'm interested in changing background color, font style and color, and windows title...

how and where have I to put those parameters?

(soz for my noobiness) :o

erpicio
Oct 13th, 2010, 02:14 PM
SOLVED!

http://img401.imageshack.us/img401/2745/catturahq.jpg

i inserted some html tags.

the following code is working:


$htmltext2 .= "<script language=\"JavaScript\">";



$htmltext2 .= "function pgpopup(pgimagefile,pgimagetitle,pgimagedescription) {\n";

$htmltext2 .= "var newWindow = window.open(\"\",\"newWindow\",\"height=" . ($tabparams["pgmaxheight"]+$dparm[2]) . ",width=" . ($tabparams["pgmaxwidth"]+$dparm[3]) . ",resizable=yes, scrollbars=yes, toolbar=no, left=20, top=20 " . "\" );\n";

$htmltext2 .= "var imageurl = \"<img src= \"+ pgimagefile + \">\";\n";

$htmltext2 .= "newWindow.document.open();";

$htmltext2 .= "newWindow.document.writeln(\"<html><head>\");\n";

$htmltext2 .= "newWindow.document.writeln(\"<title>User image: \"+ pgimagetitle + \"</title>\");\n";

$htmltext2 .= "newWindow.document.writeln(\"</head><body bgcolor=#333333><font face='Arial'; size=3; color=#367ec6><div align='center' >\");\n";

$htmltext2 .= "newWindow.document.writeln(imageurl);\n";

$htmltext2 .= "newWindow.document.writeln(\"<br />\");";

$htmltext2 .= "newWindow.document.writeln(pgimagedescription);\n";

$htmltext2 .= "newWindow.document.writeln(\"</div></body></html>\");\n";

$htmltext2 .= "newWindow.document.close();\n";

$htmltext2 .= "}\n";

$htmltext2 .= "</script>";


YAHOO!!!