1

On my Wordpress site I have a link that target a specific page in a different domain. I need to open that page and directly scroll to a specific div (identified by its class). That div doesn't have an anchor and I have no control on its code so I cannot add it. On the target site you can scroll to that div by clicking a button that triggers the following js code:

$(".call-action").click(function() {
        $('html, body').animate({
            scrollTop: $(".tuoViaggio").offset().top-$("header").height()
        }, 2000);
    });

What are my options to directly move to the div with class tuoViaggio by leveraging only the href on my domain?

4
  • 3
    If they do not have anchors and it is a different domain, there is nothing you can do. Commented Jul 15, 2019 at 15:12
  • You can try adding id to the section of domain that you want to redirect to. Then you can just append like www.example.com/#my-custom-id Commented Jul 15, 2019 at 15:15
  • you are referring to adding an anchor, not an ID. And if you read my post, I have no access to the destination domain @paudel Commented Jul 15, 2019 at 15:16
  • To be fair to @paudel, you can use the id of an element (not sure if it's any element, but definitely <div>). For instance, click here to get straight to the <div id="answers"> section of this question. So if there's a specific element with an id you can use (instead of the class) in the destination, that could be a solution?
    – freefaller
    Commented Jul 15, 2019 at 15:22

1 Answer 1

1

You can't. That's XSS (cross-site scripting)

Not the answer you're looking for? Browse other questions tagged or ask your own question.