Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I open a link in the same window and tab using the onclick event?

I have a page that has multiple divs. I want to get some information from my database to display in some of those divs and I also want it to be displayed as I click on a link to the home div.

I also need the page to be refreshed or reopened in the same window (not in a new page or tab). Last of all, I need the page to be in the home div.

I tried the code below and it didn't work:

<a href="#home" onclick="window.open('index.jsp#home')" >home</a>

<a href="#home" onclick="location.reload()">home</a>

<a href="#home" onclick="location.href='index.jsp'">home</a>
like image 626
MohammadZoghi Avatar asked Apr 21 '13 12:04

MohammadZoghi


1 Answers

I used this and it worked

<a href="#" class="home_btn" onclick="location.reload();location.href='index.jsp'">منوی اصلی</a> 
like image 185
MohammadZoghi Avatar answered Oct 25 '22 06:10

MohammadZoghi