1

I wonder if it's possible to navigate to a web page via link and zoom in to be 150%?

The only thing I could think about is to rewrite the '.click()' function and change the css there such as '-moz-transform', maybe something like this:

<!DOCTYPE html>
<meta charset="utf-8">
<html>
  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  </head>
  <body>
    <a href="https://www.google.com/search?q=kobe&igu=1" id="myLink" ></a>
  </body>
  <script>
    $('#myLink').click(function() { zoom_page() });
    function zoom_page()
    {
      // DO SOMETHING HERE!!
    }
    function autoClick() {
      document.getElementById('myLink').click()
    }
    window.addEventListener("load", autoClick);
  </script>
</html>

but not sure how exactly to do it.

Anyone can help? Thanks! Andy

Andy You
  • 101
  • 1
  • 5
  • 3
    Do you mind elaborating on why exactly you need this functionality? Changing the interface for the end user by no interaction of their own is generally terrible UX. – esqew Dec 22 '20 at 16:53
  • @esqew actually I have a Chromium based Webview which doesn't support zoom-in/out function as Chrome does, and many web contents, when rendered on it, look very small and not very readable. – Andy You Dec 24 '20 at 03:17

1 Answers1

2

Given your example uses the URL of a well-known public site which you, almost certainly. have no control over: You can't do that.

Any JavaScript you run will apply to the current page and not the next one you navigate to.

If you could run JavaScript on arbitrary third-party websites then there would be a major XSS problem everywhere.


If you had control over the destination page then you could modify it with server-side code or JS embedded in the destination page contingent on data passed from the previous page (e.g. via the URL's query string).

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • I wonder how google does it? I mean when you search something in Google (using Chrome), when you navigate to a link, the most appropriate answer for your question is lighten up at page of the site! – Zhuravlev A. Dec 22 '20 at 16:56
  • 1
    @ZhuravlevA. — That's [a feature built into Chrome](https://stackoverflow.com/questions/62989058/how-does-text-in-url-works-to-highlight-text) specifically to achieve that effect. They aren't running JS on the target site. – Quentin Dec 22 '20 at 16:56