Skip to content

Katana fails to click dynamic JavaScript-generated links (e.g., <a onclick>) even in headless mode #1358

@kayra-s4e

Description

@kayra-s4e

katana version:

v1.2.1 (latest)

Current Behavior:

Katana fails to detect links that use a combination of and JavaScript-based redirection via window.location.href. Even when running in headless mode with -system-chrome, these client-side redirects are not picked up in the output.

Expected Behavior:

I expect Katana to be able to detect dynamic links triggered via JavaScript (e.g., onclick handlers calling window.location.href) during headless crawling.

Steps To Reproduce:

  1. Host the following HTML file locally at http://localhost:9090/:
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>&lt;a&gt; Tag JS Redirect</title>
  <script type="text/javascript">
    function handleRedirect(event) {
      event.preventDefault(); 
      window.location.href = window.location.origin + "/redirected-page";
    }
  </script>
</head>
<body>
  <h1>Redirect Link</h1>
  <a href="#" onclick="handleRedirect(event)">Go to Redirected Page</a>
</body>
</html>
  1. Run the following command:
    katana -u http://localhost:9090/ --headless -system-chrome -debug
  2. Observe that the /redirected-page path is never discovered or reported.

Anything else:

This is a very basic and common JS-based redirect pattern, especially prevalent in SPAs or modern web UIs. Since the redirection is visible and accessible to real users via browser interaction, I’d expect Katana’s headless mode to simulate and capture such behavior.

Screenshot:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugInconsistencies or issues which will cause an issue or problem for users or implementors.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions