Chat Artifacts Gallery Guilds Search Wiki Login Register

Welcome, Guest. Please login or register. - Thinking of joining the forum??
April 16, 2026 - @223.43 (what is this?)
Activity rating: Three Stars Posts & Arts: 47/1k.beats Random | Recent Posts | Guild Recents
News: :happy: Open the all windows! Your mind needs storms and air! :happy: Guild Events: There are no events!

+  MelonLand Forum
|-+  Life & The Web
| |-+  ✁ ∙ Web Crafting
| | |-+  ☔︎ ∙ I need Help!
| | | |-+  troubles with javascript on neocities?


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


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

Artifacts:
Suck At Something September - Did It!bred :3Joined 2024!
« on: April 25, 2024 @180.95 »

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:
old-timey tunes~♪Flinstone VitaminAlways working hard!PoochKnown Apple shillcoolest melon on the web!
« Reply #1 on: April 25, 2024 @484.46 »

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 27 times.)
Logged


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

Artifact Swap: shoeMicrowaveAir MailCup o' JaneI met Dan Q on Melonland!poochLasagna
tertiaryapocalypse
Full Member ⚓︎
***
View Profile WWW


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

Artifacts:
Suck At Something September - Did It!bred :3Joined 2024!
« Reply #2 on: April 25, 2024 @676.39 »

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: April 27, 2024 @805.02 »

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 
« previous next »
 

Melonking.Net © Always and ever was! SMF 2.0.19 | SMF © 2021 | Privacy Notice | ~ Send Feedback ~ 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

MelonLand Nav

@000

Want to Login or Join ?

Minecraft: Online
Who: Squeaky_Cucumber