This zone is sleeping right now! ZzzZZzzz

Better not disturb it! ~You go to the petrol station and buy a slushy instead, everything is cool!~

This area will open again in 000.beats!

(Learn about Swatch Time)

Some other zones are awake :^]


Artifacts Gallery Guilds Search Wiki Login Register

Welcome, Guest. Please login or register. - Thinking of joining?
Autumn, 02 Nov 2026 - @575.80
Forum Activity: Three Stars Random | Recent Posts | Guild Recents
News: :defrag: Lo and Behold :defrag: Guild Events: November 200 words RPG jam
Super News: ~~MelonLand's Halloween Profile Design Contest 2026~~
+  MelonLand Forum
|-+  Da Web Revival
| |-+  ✁ ∙ Web Crafting
| | |-+  ☔︎ ∙ I need Help!
| | | |-+  troubles with javascript on neocities?


« previous next »
Pages: [1] Print Embed
Author Topic: troubles with javascript on neocities?  (Read 2339 times)
tertiaryapocalypse
Full Member ⚓︎
***
View Profile WWW


travelling through space at a very high speed
⛺︎ My Room
iMood: tertiaryapocalypse
Itch.io: My Games

Artifacts:
Joined 2024!
« on: Spring, 25 Apr 2024 @181 » Toggle Font Embed

have any of y'all had issues with javascript on neocities?

i'm trying to host a comic on my site, and it should hypothetically work but the conditional statements i have aren't doing what they're supposed to be. i'm not sure if it's a problem on my end, or if it's an issue with neocities in general.

(to elaborate: the site uses javascript to add or subtract from a variable that keeps track of what page number the user is on, then updates the image accordingly. that works perfectly fine. recently, though, i tried to get the music that plays on the site to change when you reach a certain page and i used a conditional (if (i>5), essentially,) to do so, and it completely messed up the pageNum variable alongside not working overall. i'd be willing to post the code here, too, if needed. here's the site.)

Logged

TERTIARYAPOCALYPSE.a button reading long gone legends in black and white with an eye icon with a star pupil
Melooon
Hero Member ⚓︎
*****
View Profile WWWArt


So many stars!
⛺︎ My Room
SpaceHey: Friend Me!
StatusCafe: melon
iMood: Melonking
Itch.io: My Games
RSS: RSS

Guild Memberships:
Artifacts:
Caught by RubbereonYou're a Star!Flinstone VitaminWavy Shoulder-Length Hair with BangsBug!Top Hat
« Reply #1 on: Spring, 25 Apr 2024 @484 » Toggle Font Embed

I had a poke around, and I'm not really sure what is not working for you - aside from a few small changes its working just fine for me!

I added setMonth(); to setPage() so that it gets called each time you load a page.

I changed your music line to this because yours had a bunch of weird extra characters in it (I also had to remove them form your initial iframe) (might have just been my browser):
Code
document.getElementById("music").src = "https://www.youtube.com/embed/" + monthlyMusicSrc[month] + "?&autoplay=1&loop=1&controls=1";

It now changes pages and the music on the pages that the code indicates it should! (A cool idea!)

(Attached the full working page)


* test.html (4.84 kB - downloaded 38 times.)
Logged


everything lost will be recovered, when you drift into the arms of the undiscovered

Artifact Swap: Have a chillpillRed TulipKigreen
tertiaryapocalypse
Full Member ⚓︎
***
View Profile WWW


travelling through space at a very high speed
⛺︎ My Room
iMood: tertiaryapocalypse
Itch.io: My Games

Artifacts:
Joined 2024!
« Reply #2 on: Spring, 25 Apr 2024 @676 » Toggle Font Embed

thanks!!
i did a bit more fiddling (including the fixes @Melooon mentioned) and it should change the music based on both the page number and the prev/next button (i added a conditional on the navigation functions that changes the music if it's on a certain page!)

Logged

TERTIARYAPOCALYPSE.a button reading long gone legends in black and white with an eye icon with a star pupil
bees
Full Member
***
View Profile WWW


⛺︎ My Room
iMood: lobb

Artifacts:
Great Posts PacmanJoined 2024!
« Reply #3 on: Spring, 27 Apr 2024 @805 » Toggle Font Embed

The song "Empty Town" isn't playing for me :( The one in the other chapter works fine, though!

(Also, idk if that's meant to be that way for now, but clicking "chapters" just keeps me on the main reading page.)

Logged

Pages: [1] Print Embed 
« previous next »
 

Melonking.Net © Always and ever was! SMF 2.0.19 | SMF © 2021 | Privacy Notice | Send Feedback | Supporters ♥ Forum Guide | Rules | RSS | WAP | Mobile


MelonLand Badges and Other Melon Sites!

MelonLand Project! Visit the MelonLand Forum! Support the Forum
Visit Melonking.Net! Visit the Gif Gallery! Pixel Sea TamaNOTchi
@000 Melon
Land
Forum Art Hub Chat Webring Explore Random Recent Tenement Arcade Want to Login or Join ? Web Craft Guide Graphic Catalogue Wiki Help I'm Lost! Link Land Newsletters Image Stream Minecraft: Online
Zap!
Passport Sites tamaNOTchi Asatte Add your site?
Aero Archive Onio Cafe 32 Bit Cafe Status Cafe