Welcome,
Guest
.
Please
login
or
register
.
Did you miss your
activation email
?
News:
Elxis 5.5 Calypso supports 2 factor authentication login with e-mail or SMS.
Home
Help
Login
Register
Elxis CMS Forum
»
Support
»
General
(Moderators:
Ivan Trebješanin
,
Farhad Sakhaei
) »
Display scripts in a module content
« previous
next »
Print
Pages: [
1
]
Author
Topic: Display scripts in a module content (Read 2445 times)
armpouniotis
Sr. Member
Posts: 377
Display scripts in a module content
«
on:
April 27, 2020, 16:57:31 »
Hi there !
I want to make a module_content, and inside that I want to display this (it is a script that displays current time):
<script>
function startTime() {
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
m = checkTime(m);
s = checkTime(s);
document.getElementById('txt').innerHTML =
h + ":" + m + ":" + s;
var t = setTimeout(startTime, 500);
}
function checkTime(i) {
if (i < 10) {i = "0" + i}; // add zero in front of numbers < 10
return i;
}
</script>
</head>
<body onload="startTime()">
<div id="txt"></div>
Can I do that inside the text editor ?
Thank you in advance
Christos
Logged
Christos Armpouniotis
datahell
Elxis Team
Hero Member
Posts: 10356
Re: Display scripts in a module content
«
Reply #1 on:
April 27, 2020, 21:21:15 »
No, and it is a very bad idea to insert javascript in editor. Put your javascript in an external js file and load it in your template. In module's html area put just the html.
$eDoc->addScriptLink('
https://www.example.com/something/blahblah.js');
$eDoc->addNativeDocReady('startTime();');
«
Last Edit: April 27, 2020, 21:24:08 by datahell
»
Logged
Elxis Team
|
Is Open Source
|
IOS Rentals | IOS AERO
armpouniotis
Sr. Member
Posts: 377
Re: Display scripts in a module content
«
Reply #2 on:
April 27, 2020, 22:36:44 »
It works better than I thought !
Thank you !
Christos
Logged
Christos Armpouniotis
Print
Pages: [
1
]
« previous
next »
Elxis CMS Forum
»
Support
»
General
(Moderators:
Ivan Trebješanin
,
Farhad Sakhaei
) »
Display scripts in a module content