Page 1 of 1

onclick() function - how to link to page?

Posted: Tue Feb 02, 2010 1:00 am
by rrn
this is my html page..

Code: Select all

 
<html>
<head>
<script type="text/javascript" language="JavaScript">
function general_formats()
{
window.open('http://www.test.com/general_formats.php');
}
</script>
</head>
<body>
<a href="general_formats.php"><onclick="general_formats(); return false">General Formats</a>
</body>
</html>
When i click ' General Formats ' , a window is opened , i dont need that .
What i need is , when i click the link , it should direct to general_fomats.php..

please help me to solve it . .any help will be appreciated .

Re: onclick() function - how to link to page?

Posted: Tue Feb 02, 2010 9:53 am
by lshaw
Change the line

Code: Select all

 
window.open('http://etc.com');
 
to

Code: Select all

 
window.location='http://etc.com';
 
That is untested but I am sure you get the idea :D

window.open will always open a new window (depending on the users browser settings :D )

Re: onclick() function - how to link to page?

Posted: Tue Feb 02, 2010 11:40 am
by kaszu
it should be 'document', not 'window'

Code: Select all

document.location = 'http://etc.com';

Re: onclick() function - how to link to page?

Posted: Tue Feb 02, 2010 11:42 pm
by rrn
window.location = ""
worked ...
Thank you guys.......

Re: onclick() function - how to link to page?

Posted: Sun Feb 07, 2010 10:02 am
by xjake88x
I always use

Code: Select all

location.href='http://....';
. Old school?