Click here to Skip to main content
15,843,149 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I'm facing problem in a simple website, where i'm using buttons to switch between different pages,
behind the every button i'm using onclick() method to open other page.
Method i'm using is onclick = "windows.open('xyz.html')" of javascript.
but when i do click on a button to open a specific page , that specific page does not open, another page become appear instead.
Note: website is placed on server of apachi(wamp server) using php there.
Posted
Updated 20-Aug-14 9:15am
v3
Comments
Shimul Chowdhury 20-Aug-14 14:32pm    
Can you clarify what you mean by another page become appear instead?
Ammar Shaukat 20-Aug-14 22:05pm    
that page appears which is not written on click event..

C#
function loadHome()
{
  window.location.assign('../index.php');
}
 
Share this answer
 
Try to use following
JavaScript
onClick = " window.location = 'http://www.yoururl.com/xyz.html'"

Or
JavaScript
onClick = " window.navigate('http://www.yoururl.com/xyz.html')"
 
Share this answer
 
v3
Comments
Ammar Shaukat 21-Aug-14 13:34pm    
it is okay.. i'm using windows.open('url');
is it wrong?

Here is a solution:


JavaScript
window.location.replace("http://yourwebsite.com/page1.php");

or


JavaScript
window.location.href("http://yourwebsite.com/page1.php");
 
Share this answer
 
Comments
Ammar Shaukat 24-Aug-14 6:13am    
you mean to say this problem is because of that function which i'm using...?
actully i want to see ,, where is the problem ...?
The problem is here:
onclick = "windows.open('xyz.html')"

The good solution:
onclick=javascript:window.location.replace("http://yourwebsite.com/page1.php")

or use this:
onclick="Navigate()"

JavaScript
function Navigate()
 {
window.location.assign("http://yourwebsite.com/page1.php");
 }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900