Page 1 of 11
Forum moderator: bigblog 
uCoz Community » For Webmasters » Custom Solutions » where do you save javascript code?
where do you save javascript code?
terminasyanarmen
Posts: 20
Reputation: 0

Message # 1 | 7:47 PM
Where do you save javascript code files? And how to make them accessible from html files?

Reason:
I need to add tabs for text so people can choose between two texts conveing the same message in two languages
http://www.w3schools.com/howto/howto_js_tabs.asp
Post edited by terminasyanarmen - Friday, 2016-05-06, 7:48 PM
bigblog
*boops*
Posts: 1430
Reputation: 67

Message # 2 | 6:54 AM
terminasyanarmen, you can upload the JavaScript files through the File Manager (Control Panel » File Manager). After that, you only need to implement the file in the page, before the </body> tag:
Code
<script type="text/javascript" src="/path/file.js"></script>

hey i'm joe, please don't call me on my real name because you're gonna misspell or mispronounce it and it drives me nuts
terminasyanarmen
Posts: 20
Reputation: 0

Message # 3 | 11:54 PM
Thanks, this works perfectly. Only one issue. Unless I click one of the tab, there is no "default tab", no text is shown until one of the tabs is clicked, only the tabs are shown. How to make the first tab content shown even before any tab is clicked?

used the exact CSS and JS codes as in here: http://www.w3schools.com/howto/howto_js_tabs.asp
JS script uploaded and linked to in the html code as you explained.
Post edited by terminasyanarmen - Saturday, 2016-05-07, 11:55 PM
bigblog
*boops*
Posts: 1430
Reputation: 67

Message # 4 | 8:20 AM
terminasyanarmen, please, provide the URL address of the page where you have inserted the code.
hey i'm joe, please don't call me on my real name because you're gonna misspell or mispronounce it and it drives me nuts
terminasyanarmen
Posts: 20
Reputation: 0

Message # 5 | 4:11 PM
There you go: http://makegamesfast.at.ua/#
Before you click any tab no text is shown.

Added (2016-05-11, 4:11 PM)
---------------------------------------------
Hello?

bigblog
*boops*
Posts: 1430
Reputation: 67

Message # 6 | 6:51 PM
terminasyanarmen, try to add
Code
openCity("London")

and a line break to the beginning of the JavaScript code.

hey i'm joe, please don't call me on my real name because you're gonna misspell or mispronounce it and it drives me nuts
terminasyanarmen
Posts: 20
Reputation: 0

Message # 7 | 7:41 PM
Didn't do anything I'm afraid.
SanTLee
Posts: 46
Reputation: 3

Message # 8 | 11:42 PM
Quote bigblog ()
terminasyanarmen


try to add

I- "active" to class="tablinks"
<li><a href="#" class="tablinks active" onclick="openTab(event, 'London')">London</a></li>

II- style="display:block" to class="tabcontent"
<div id="London" class="tabcontent" style="display:block">

<?if(you_have)?> a <head>and<?if(you_have)?> a <body> you have to have
<div id="idea" class="extreme" > to be inventive </div><?endif?><?endif?>
terminasyanarmen
Posts: 20
Reputation: 0

Message # 9 | 11:49 PM
That sadly didnt change anything either
SanTLee
Posts: 46
Reputation: 3

Message # 10 | 0:19 AM
Quote terminasyanarmen ()
That sadly didnt change anything either


Add to JS

Code
var mybtn = document.getElementsByClassName("tablinks")[0];
mybtn.click();

<?if(you_have)?> a <head>and<?if(you_have)?> a <body> you have to have
<div id="idea" class="extreme" > to be inventive </div><?endif?><?endif?>
terminasyanarmen
Posts: 20
Reputation: 0

Message # 11 | 0:26 AM
I understand what that is meant to do, but emulating a tab click doesn't seem to work as well...

EDIT: Sorry, it does work smile Thank you.
It didn't work because I put the code inside the function definition.
Post edited by terminasyanarmen - Thursday, 2016-05-12, 0:30 AM
uCoz Community » For Webmasters » Custom Solutions » where do you save javascript code?
Page 1 of 11
Search: