11

Change browser address bar URL with jQuery without reloading For example,

www.mywebsite/list.php?page=1

<a href="?page=<?php $row[id] ?>" > this link </a>

on click change address bar ?id=123 etc...

Jaffa
  • 12,442
  • 4
  • 49
  • 101
Shauzab Ali
  • 111
  • 1
  • 1
  • 3

3 Answers3

5

not possible at all to change the url or even query string of the browser without reloading only part you can change without refresh is #hash part of the url till html4

But in html 5 some kind of url change can be done by the new HISTORY API give it a try

http://html5demos.com/history

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
GajendraSinghParihar
  • 9,051
  • 11
  • 36
  • 64
2

You can not. If you try to do it like this for example:

document.location.search= "?i=123"

It will reload the page. What you can do is change the hash

document.location.hash= "#123"

or

document.location.hash= "#i=123

And then write a simple parsor using split to grab the data you need. Similar question you should have a look at.

Community
  • 1
  • 1
3on
  • 6,291
  • 3
  • 26
  • 22
  • Note that # (hash) params cannot be read on server side like ? (query) params - initial usage of # in urls is for "go-to anchor/id" functionality – Ivan Hušnjak Aug 29 '12 at 07:21
2

jQuery: pjax plugin may help you.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Jonas
  • 71
  • 2