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,305
  • 4
  • 38
  • 60
User42590
  • 2,477
  • 11
  • 42
  • 84

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,420
  • 6
  • 49
  • 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,379
  • 2
  • 19
  • 39