0

The page URL has to change when the loadTest() function is called on a ahref click. But the page is getting refreshed only when alert is included in the code. If I remove the alert the same page is getting refreshed and not the new URL which I need.

<script type="text/javascript">
function loadText(prod_id)
{
        curUrl = document.location.href.split("?");
        document.location = curUrl[0]+'?prodId='+prod_id;
    alert("Test");
}
</script>
stecb
  • 14,478
  • 2
  • 50
  • 68
i2ijeya
  • 15,952
  • 18
  • 63
  • 72

2 Answers2

3

use window.location instead of document.location

function loadText(prod_id)
{
        curUrl = window.location.split("?");
        window.location = curUrl[0]+'?prodId='+prod_id;
}
niksvp
  • 5,545
  • 2
  • 24
  • 41
  • @i2ijeya - see I updated your function.. Did u do the same? else can you paste the `html` from where u are calling the function? – niksvp Jun 03 '11 at 10:02
1
window.location = curUrl[0]+'?prodId='+prod_id;
Farshid Zaker
  • 1,960
  • 2
  • 22
  • 39