/    Sign up×
Community /Pin to ProfileBookmark

How to scroll to anchor using “window.location.href”?

I’m having some problems with a simple task. I have a popup on a WordPress page, which is an element without an id. I need to take the user to a certain location on the same page when it clicks it.

The popup uses the method “window.location.href” to redirect the user. For some reason, if I define it as an anchor, it just doesn’t work. I tried several things (different hashes and syntax combinations, tried to select the popup using ClassName[0] and then setting on an id, so that it can manages its onclick), but nothing worked.

The popup is generated/managed through a plugin (Ninja Popups), so it’s not something I’d really wanted to mess with…

Is there any way to make the method “window.location.href” work with an anchor? I can insert some JS, I just can’t modify the system or the plugin itself.

Here is the link if you want to check by yourselves: https://quintaldoespeto.com.br/

to post a comment
HTMLJavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@VITSUSAJul 28.2020 — You can do it but more pop-ups will not helpful to you :)
×

Success!

Help @mateus-qde spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...