Home Events! Entrance Everyone Wiki Search Login Register

Welcome, Guest. Please login or register. - Thinking of joining the forum??
December 03, 2024 - @784.80 (what is this?)
Forum activity rating: Two Stars Posts: 24/1k.beats Unread Topics | Unread Replies | My Stuff | Random Topic | Recent Posts    Start New Topic
News: :happy: Open the all windows! Your mind needs storms and air! :happy:

+  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 749 times)
tertiaryapocalypse
Jr. 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

View Profile WWW

Thanks for being rad!a puppy for your travelsAlways My PalFirst 1000 Members!spring 2023!Squirtle!!!!MIDI WarriorMIDI Warrior1234 Posts!OzspeckCool Dude AwardRising Star of the Web AwardMessage BuddyPocket Icelogist!OG! Joined 2021!...
« 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 9 times.)
Logged


everything lost will be recovered, when you drift into the arms of the undiscovered
tertiaryapocalypse
Jr. 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
Jr. Member ⚓︎
**


⛺︎ My Room
iMood: lobb

View Profile WWW

Joined 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 »
 

Vaguely similar topics! (3)

HELP: troubles in implementing iframe to my existing layout

Started by morrysillusionBoard ☔︎ ∙ I need Help!

Replies: 8
Views: 2189
Last post June 07, 2022 @522.55
by Melooon
I need help with neocities

Started by Kane VirkutisBoard ☔︎ ∙ I need Help!

Replies: 1
Views: 1888
Last post February 25, 2022 @609.50
by Melooon
Where are IPFS backups on Neocities? ANSWERED!

Started by ellievoyydBoard ✁ ∙ Web Crafting

Replies: 3
Views: 2280
Last post March 17, 2022 @162.86
by PAINTKILLER

Melonking.Net © Always and ever was! SMF 2.0.19 | SMF © 2021, Simple Machines | Terms and Policies 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