-1

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>

2 Answers 2

3

use window.location instead of document.location

function loadText(prod_id)
{
        curUrl = window.location.split("?");
        window.location = curUrl[0]+'?prodId='+prod_id;
}
Sign up to request clarification or add additional context in comments.

1 Comment

@i2ijeya - see I updated your function.. Did u do the same? else can you paste the html from where u are calling the function?
1
window.location = curUrl[0]+'?prodId='+prod_id;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.