Page 1 of 1

HTML module: Running Java script?

Posted: Wed Jun 08, 2016 4:39 am
by i2Paq
In my "old" 1.5.4.1 store I'm running a Java script in an additional CR2 HTML module and this works fine.

Now I want to do the same in my new 2.2.0.0 store in the HTML module.

All I see is the code itself.

What am I missing?

Code: Select all

<script type="text/javascript">
    <!--
    var now = new Date();
    var url;

    var image1 = new Image();
    image1.src="http://cdn.knmi.nl/knmi/map/page/weer/waarschuwingen_verwachtingen/zonkracht/zonkracht_dag0.gif?"+now.getHours()+now.getMinutes()+now.getSeconds();
    url= '<img id="zonkrachtverwachting" src="'+image1.src+'" width="160" border=0 vspace=0 hspace=0 valign=top usemap="#zonkracht_verwachting">';
    document.writeln( url );
    //-->
    </script>
    <noscript>
    <img id="zonkrachtverwachting" src="http://cdn.knmi.nl/knmi/map/page/weer/waarschuwingen_verwachtingen/zonkracht/zonkracht_dag0.gif" border=0 vspace=0 hspace=0 valign=top usemap="#zonkracht_verwachting">
    </noscript>
    <map name="zonkracht_verwachting">
    <area shape="rect" alt="Zonkrachtverwachting dag 1" coords="15,176,157,185" href="http://www.knmi.nl/nederland-nu/weer/waarschuwingen-en-verwachtingen/zonkracht" target="_blank" title="Zonkrachtverwachting dag 1">
    <area shape="rect" alt="Zonkrachtverwachting dag 2" coords="15,186,157,194" href="http://www.knmi.nl/nederland-nu/weer/waarschuwingen-en-verwachtingen/zonkracht" target="_blank" title="Zonkrachtverwachting dag 2">
    <area shape="rect" alt="Informatie over de zonkracht" coords="149,0,159,10" href="http://www.knmi.nl/nederland-nu/weer/waarschuwingen-en-verwachtingen/zonkracht" target="_blank" title="Informatie over de zonkracht" target="legenda">
    <area shape="rect" alt="Verwachte zonkracht voor de komende dagen" coords="9,23,154,139" href="http://www.knmi.nl/nederland-nu/weer/waarschuwingen-en-verwachtingen/zonkracht" target="_blank" title="Verwachte zonkracht voor de komende dagen">
    <area shape="default" nohref>
    </map>
The funny thing is that when I click on Source view and add the code and click on Source view again it will show what I should see on my store front.

Re: HTML module: Running Java script?

Posted: Tue Jun 14, 2016 1:02 am
by inactiveaccount9912
Use it like below and it will work the same.

Code: Select all

<div id="zonkrachtverwachtingdiv"></div>
    <script type="text/javascript">
    <!--
    var now = new Date();
    var url;

    var image1 = new Image();
    image1.src="http://cdn.knmi.nl/knmi/map/page/weer/waarschuwingen_verwachtingen/zonkracht/zonkracht_dag0.gif?"+now.getHours()+now.getMinutes()+now.getSeconds();
    url= '<img id="zonkrachtverwachting" src="'+image1.src+'" width="160" border=0 vspace=0 hspace=0 valign=top usemap="#zonkracht_verwachting">';
    document.getElementById("zonkrachtverwachtingdiv").innerHTML=url; 
    //-->
    </script>
    <noscript>
    <img id="zonkrachtverwachting" src="http://cdn.knmi.nl/knmi/map/page/weer/waarschuwingen_verwachtingen/zonkracht/zonkracht_dag0.gif" border=0 vspace=0 hspace=0 valign=top usemap="#zonkracht_verwachting">
    </noscript>
    <map name="zonkracht_verwachting">
    <area shape="rect" alt="Zonkrachtverwachting dag 1" coords="15,176,157,185" href="http://www.knmi.nl/nederland-nu/weer/waarschuwingen-en-verwachtingen/zonkracht" target="_blank" title="Zonkrachtverwachting dag 1">
    <area shape="rect" alt="Zonkrachtverwachting dag 2" coords="15,186,157,194" href="http://www.knmi.nl/nederland-nu/weer/waarschuwingen-en-verwachtingen/zonkracht" target="_blank" title="Zonkrachtverwachting dag 2">
    <area shape="rect" alt="Informatie over de zonkracht" coords="149,0,159,10" href="http://www.knmi.nl/nederland-nu/weer/waarschuwingen-en-verwachtingen/zonkracht" target="_blank" title="Informatie over de zonkracht" target="legenda">
    <area shape="rect" alt="Verwachte zonkracht voor de komende dagen" coords="9,23,154,139" href="http://www.knmi.nl/nederland-nu/weer/waarschuwingen-en-verwachtingen/zonkracht" target="_blank" title="Verwachte zonkracht voor de komende dagen">
    <area shape="default" nohref>
    </map>

Re: HTML module: Running Java script?

Posted: Tue Jun 14, 2016 1:59 am
by i2Paq
Thanks!

It sure works :D

Re: HTML module: Running Java script?

Posted: Sat Jul 02, 2016 8:35 am
by labeshops
having problems running javascript in the html module. Trying to put in the following into the module so I can use it in several places, but when I save in the html module, it wipes out the code. Thought perhaps the html module in 2.2 didn't support javascript, but then saw this post so wondering wth I'm doing wrong?

Code: Select all

<script language="JavaScript" type="text/javascript">
TrustLogo("https://www.domain.com/image/catalog/comodo_secure_seal_76x26_transp.png", "CL1", "none");
</script>
<a  href="https://www.instantssl.com/" id="comodoTL">
SAFE & SECURE</a>


Re: HTML module: Running Java script?

Posted: Sat Jul 02, 2016 7:11 pm
by inactiveaccount9912
After you added the code in source mode of summernote, switch back to view mode before saving.

Re: HTML module: Running Java script?

Posted: Sat Jul 02, 2016 8:28 pm
by labeshops
florinsith wrote:After you added the code in source mode of summernote, switch back to view mode before saving.
I normally do, but for some reason it won't let me when I add this code. It's like the <> button is stuck.

Re: HTML module: Running Java script?

Posted: Sun Jul 03, 2016 2:31 am
by IP_CAM
Even for very a simple task, like adding the img-responsive class tag (in source mode) to a Product Description Section Image, I had to switch back to WysiWyg Mode, to keep it existing in Place, and working, exactly contrary to, what I am used to do in the cKeditor.

But, as I found out, Summernote has made many improvements/updates, (still not even V.1.0 YET!!) and OC v.2.2 still used an outdated pre-release Version, so, I would, if I would care about, at least install the latest Summernote from Github, and then, try again ! :D
Ernie

Re: HTML module: Running Java script?

Posted: Sun Jul 03, 2016 3:59 am
by labeshops
thanks. tried updating summernote to the newest version and it still will not go back out of code view when I use my code. when I tried the script the op had here, it worked fine, so wondering if there is something wrong with the trustseal code I'm trying to use that I'm missing??

Re: HTML module: Running Java script?

Posted: Mon Jul 04, 2016 9:17 pm
by inactiveaccount9912
Use it like this:

Code: Select all

<script language="JavaScript" type="text/javascript">
if(typeof TrustLogo == 'function') {
TrustLogo("https://www.domain.com/image/catalog/comodo_secure_seal_76x26_transp.png", "CL1", "none");
}
</script>
now it wont do anything in admin and youll be able to save. It will work in front as long as that function does exist.

Re: HTML module: Running Java script?

Posted: Tue Jul 05, 2016 3:19 am
by labeshops
You are awesome!! Thanks. That worked :)