Artifacts Gallery Guilds Search Wiki Login Register

Welcome, Guest. Please login or register. - Thinking of joining?
a Summer night - @966.69
Activity rating: Four Stars Posts & Arts: 53/1k.beats Random | Recent Posts | Guild Recents
News: inconvenience is counterculture :eyes: Guild Events: HOMESTUCK ART-APALOOZA

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


« previous next »
Pages: [1] Print Embed
Author Topic: troubles with javascript on neocities?  (Read 2128 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: a Spring night » 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:
You're a Star!I got robbed by Dan Q on Melonland!Flinstone VitaminAlways working hard!Known Apple shillcoolest melon on the web!
« Reply #1 on: a Spring day » 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 29 times.)
Logged


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

Artifact Swap: Visited on Melon's 10th Anniversary!Wildflowers!bitsy catRed TulipMellohiI met Dan Q on Melonland!?Flowers
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: a Spring day » 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: a Spring night » 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
MelonLand @000

Want to Login or Join ?

Minecraft: Online
Join: craft.melonking.net