0

I have pass value from windows.location.href like

window.location.href = 'index.html#one?narrat='+narration;

now i want to get this value from "index" page but how.

How i can get this value in index page?

pbaris
  • 4,525
  • 5
  • 37
  • 61
User42590
  • 2,473
  • 12
  • 44
  • 85

2 Answers2

0

For this specific question, this will give you the value of narat...

var narat = location.href.substr(location.href.search("\\?")).split("=")[1];

or even simpler...

var narat = location.href.split("narat=")[1];

If you are adding more variables to the querystring then it will need parsing differently.

Reinstate Monica Cellio
  • 25,975
  • 6
  • 51
  • 67
-1

If i also understood your question right .

var loc = 'index.html#one?narrat='+narration;
window.location.href = 'index.html#one?narrat='+narration;

now you can acces this variable

Ashisha Nautiyal
  • 1,389
  • 2
  • 19
  • 39