This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
programmieren:javascript:url_mit_paramatern_aendern_und_laden [2022/01/31 20:19] – created jgehrke | programmieren:javascript:url_mit_paramatern_aendern_und_laden [2022/12/17 12:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Javascript: Browser URL mit GET Parametern ändern ====== | ||
+ | Dieser Code liest die Browser URL aus, trennt sie in Ihre Komponenten Server Host, Pfad/Path und GET Parametern. Einer der GET-Parameter wird neu gesetzt und die aktualisierte URL wird aufgerufen. | ||
<code javascript> | <code javascript> | ||
- | const url_host | + | const url_host |
- | const url_path | + | const url_path |
- | | + | const url_search_string = window.location.search; |
- | const url_new_p | + | |
- | const new_url | + | url_params_object.set( 'other_param', |
+ | const url_params_string | ||
+ | const new_url | ||
window.location.replace( new_url ); | window.location.replace( new_url ); | ||
</ | </ | ||
+ | |||
+ | **Hinweis: | ||
+ | |||
+ | **MDN Doku:** | ||
+ | * [[https:// | ||
+ | * [[https:// |