-2

How to read values from header url in javascript?

For example if I have something like:

www.something.com/details.html?test=something

I need to be able to read this data when I redirect to page details.html.

What would be a good approach for this? Maybe adding some php code to get data?

user123_456
  • 5,635
  • 26
  • 84
  • 140

1 Answers1

0

Are you talking about getting the value from a get variable and using it in javascript? If so I've used something similar to this before:

<script type="text/javascript">
function myfunction(){
     var value = "<?php echo $_GET['test']; ?>"
}
</script>

And it's worked beautifully for me.

Blunderfest
  • 1,854
  • 1
  • 28
  • 46