Entrance Chat Gallery Guilds Search Everyone Wiki Login Register

Welcome, Guest. Please login or register. - Thinking of joining the forum??
July 15, 2025 - @728.19 (what is this?)
Activity rating: Three Stars Posts & Arts: 38/1k.beats Unread Topics | Unread Replies | My Stuff | Random Topic | Recent Posts Start New Topic  Submit Art
News: :4u: Love is not possession  :4u: Super News: Upload a banner!

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


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


travelling through space at a very high speed

⛺︎ My Room
iMood: tertiaryapocalypse
Itch.io: My Games

View Profile WWW

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 ⚓︎
*****


So many stars!

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

View Profile WWWArt

a silly heart 4 melon :)Ozwomp wants to know your locationHyperactive DonutGreat Posts PacmanOfficially DogThanks for being rad!
« 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 12 times.)
Logged


everything lost will be recovered, when you drift into the arms of the undiscovered
tertiaryapocalypse
Full Member ⚓︎
***


travelling through space at a very high speed

⛺︎ My Room
iMood: tertiaryapocalypse
Itch.io: My Games

View Profile WWW

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 ⚓︎
***


⛺︎ My Room
iMood: lobb

View Profile WWW

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