0

I have a webpage and the current URL format is as so:

http://10.xx.xxx.xxx/d/8xi8UU6ik/usgm-xxxx_testsim_gth?orgId=1&from=now-3h&to=now&var-gdb=text555xxx

Where &from=now-3h&to=now is the time selector

On this page I have a input button that opens another URL.

<input type="button1" class="button1" value="APM"onclick="window.open('$appdash')"/>

And a JS snippet:

<script>
onclick="window.open(this.href,'popUpWindow','height=400,width=600,left=10,top=10,,scrollbars=yes,menubar=no'); return false;"
</script>

Where $appdash URL is defined elsewhere as:

https://mysite.analytics.com/dashboard/db/test-homepage-cdc?refresh=1m&orgId=1

What I need is to add something to the javascript snippet so when I press the button

  1. Gets the current URL
  2. Uses regex to get time selector
  3. appends 2nd URL with time selector

I have a working regex pattern that should do the trick,

(?<=orgId=1)(.*?)(?=&var-gdb)

I need something like the end result when the button pressed the below page opens.

https://mysite.analytics.com/dashboard/db/test-homepage-cdc?refresh=1m&orgId=1&from=now-3h&to=now

Not fully versed in how to use regex in JS so any pointers!

Luke Toss
  • 356
  • 5
  • 23

0 Answers0