Skip to content

[bug] Cannot use URL parameters with window.location.href #8148

@brendanosborne

Description

@brendanosborne

Describe the bug

I am unable to use URL parameters with window.location.href

This works:
window.location.href = 'test.html'

But this doesn't work:
window.location.href = 'test.html?test=test'

The console outputs "Navigated to http://127.0.0.1:1430/test.html?test=test" but the page does not change.

I am using plain HTML with no build tools or frameworks. I have also tried using the following but it returns the same result:

window.location.href = encodeURIComponent(test.html?test=test, 'UTF-8')})

Reproduction

I was able to reproduce the problem in a freshly created Tauri HTML app.

Expected behavior

It should route to test.html and the URL params should be available in the test.html page.

Platform and versions

[✔] Environment
    - OS: Windows 10.0.19045 X64
    ✔ WebView2: 118.0.2088.76
    ✔ MSVC: Visual Studio Community 2022
    ✔ rustc: 1.72.0 (5680fa18f 2023-08-23)
    ✔ cargo: 1.72.0 (103a7ff2e 2023-08-15)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)  
    - node: 18.18.0
    - yarn: 1.22.19
    - npm: 10.1.0

[-] Packages
    - tauri [RUST]: 1.5.2
    - tauri-build [RUST]: 1.5.0
    - wry [RUST]: 0.24.4
    - tao [RUST]: 0.16.5
    - @tauri-apps/api : not installed!
    - @tauri-apps/cli [NPM]: 1.5.6

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../src
    - devPath: ../src

Stack trace

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions