0

I am calling the js function from the href

function topicApproval()
{
 var approve = confirm('Do you wish to proceed?');
 if(approve)
 {
 window.location('http://www.sample.com');
 }
}

Here is the function called Yes

But it is not redirecting........ Please help me..

1
  • Does Firebug console mention any errors? Commented Oct 25, 2011 at 9:25

3 Answers 3

5

Use:

window.location = 'http://sample.com';

More info

Sign up to request clarification or add additional context in comments.

Comments

4

You cal also use

window.location = 'http://sample.com';
window.location.href="http://www.example.com/";  and
window.location.replace('example.html');

for more details here

1 Comment

Thanks for the answer.It works when I put one alert message like window.location.replace('sample.com/'); alert("HI"); Why this happens due to time delay or something help.................
1

Why not using document.location.href = 'http://location.com' which is supported by every browser.

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.