VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: dfin on December 15, 2014, 21:11:28 PM

Title: Adding Javascript to homepage
Post by: dfin on December 15, 2014, 21:11:28 PM
If this is in wrong section, forgive me.

I'm wanting to add a pop-up window to the homepage, & have resorted to trying to add a custom html module called 'myJavacript' & assigning it to the homepage there...problem is, the code is stripped out & some tries results in  being written out on the page versus sticking to a backend code to be read.

In the html editor, in the code portion...I put either
Quote<?php
$document = JFactory::getDocument();
$document->addScriptDeclaration('
    window.open ('popup.html', 'newwindow', config='height=550, width=600, toolbar=no, menubar=no, scrollbars=no, resizable=no,
location=no, directories=no, status=no');
    );
');
?>

or plain old
Quote<SCRIPT LANGUAGE="javascript">

window.open ('popup.html', 'newwindow', config='height=550,

width=600, toolbar=no, menubar=no, scrollbars=no, resizable=no,

location=no, directories=no, status=no')

</SCRIPT>

First way writes the middle code out & last way does nothing....what am I doing wrong & is there another method to go about this?

Thank you.
Title: Re: Adding Javascript to homepage
Post by: dfin on December 15, 2014, 21:46:46 PM
I added an extension to not strip the code....so now the text editor in a module I made has...
Quote{source}

<?php
$document = JFactory::getDocument();
$document->addScript('http://website.com/MY-JS.js');
?>

{/source}
Then in the MY-JS.js I have a function to open a new window...& it still isn't working?
Title: Re: Adding Javascript to homepage
Post by: dfin on December 15, 2014, 22:33:53 PM
Nevermind....I fixed it.