A
A
AntonMSbor2021-08-27 17:33:01
JavaScript
AntonMSbor, 2021-08-27 17:33:01

How to make window.location.href and url.searchparam.get work on IE10+?

Hello!
Faced with the situation of ensuring the performance of a simple JS code on IE version 9 and higher.

There is an email that forms a link to a third-party page in the format site.rf/section/index.php?znum=IR1234567&surv=cr101, where znum and surv are variables processed on the final page using zurl.searchParams.get("znum" ) and further fitting into via _znum.value.
On chrome, ff and even edge - it works. On IE - stupidly does not fit anything.
Please help with alternative ways to implement this code under IE. Thank you!

Code below.

var zurl = new URL(location.href);
var _znum = zurl.searchParams.get("znum");

zid.value= _znum;

<input id="zid" type="text">

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Kulakov, 2021-08-28
@ivankprod

Parse parameters manually without using new URL()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question