Skip to content
Sign upLog in
← Back to Community

Why is my javascript not working on all of my pages?

Profile icon
Jose_CC

I´ve tried to connect my JS(script.js) to other files on my project, only works with index.html. here is my project https://repl.it/@Jose_CC/Photo-page-project . Please help, I love relp! I dont want to stop using it because of a small problem like this

Voters
Profile icon
0DaIsY0
Profile icon
GabrielSousa2
Profile icon
liseguillon
Profile icon
AmelieTucker
Profile icon
Jose_CC
Comments
hotnewtop
Profile icon
HappyFakeboulde

You know there's such a thing as screenshots, right?

Profile icon
timmy_i_chen

Just want to check: I see that you are testing within the workspace page, which really only shows index.html and will never load any other html file - therefore, any div elements you have existing in other files will never be loaded onto the page. If you open it in a new tab and test it there, navigating to different files, does it work there as expected?

Profile icon
Jose_CC

@timmy_i_chen No, only works if I´m in the current page. For example, if I´m in index.html and I try to select something from about.html the result will be nun, but if I´m in the about page it´ll select the ID.

Profile icon
timmy_i_chen

@Jose_CC Can you share with us a repl that reproduces this issue on a small scale? There's a lot going on in the photo page project.

Profile icon
Jose_CC

@timmy_i_chen
IMG_20181210_230100

Profile icon
timmy_i_chen

@Jose_CC I mean, can you reproduce this minimally in a new repl?

Profile icon
Jose_CC

@timmy_i_chen sure, give me a few minutes. thank you for your time

Profile icon
Jose_CC

so sorry for the waiting, I had some issues with my phone camera.
https://repl.it/@Jose_CC/AshamedNoxiousAddons
@timmy_i_chen
IMG_20181210_231856


IMG_20181210_231915 (1)

IMG_20181210_231915

IMG_20181210_231929

IMG_20181210_231948

Profile icon
Jose_CC

@timmy_i_chen is that ok? I still have the same problem

Profile icon
timmy_i_chen

@Jose_CC Yes, I can see now - thanks for reproducing. This is working as expected:

Cannot infer image mime type

The thing is, whenever you re-run the repl, it will always go back to index.html, which is why it can't find #two-try. If you try by popping out the browser it should be a lot more clear.

Profile icon
Jose_CC

@timmy_i_chen Mannnnn! thank you so much!!!!! I´m so happy right now!

Profile icon
timmy_i_chen

@Jose_CC No problem! :)

Profile icon
Jose_CC

Here are more examples of my problem, thank you in advance

IMG_20181210_223440 (1)


IMG_20181210_223447

IMG_20181210_223445

IMG_20181210_223430

IMG_20181210_223425

Profile icon
Vandesm14

Make sure your JQuery is included on every page.

Cannot infer image mime type

Please upvote this comment if it helped you in any way.

Profile icon
Jose_CC

@Vandesm14
Than you for replying, I created a new ID and added a link to jQuery to the about page, I´ve tried to select the ID using plain js and jquery and nothing.
IMG_20181210_221759

IMG_20181210_221806

Profile icon
HappyFakeboulde

Are you sure it works with only index.html?

Profile icon
Jose_CC