简体   繁体   中英

HTML onclick div id goto both href

I have the .onclick function bound to a (div id) which will take it to another page once it is clicked ( onclick="location.href='homepage.html';" )

<div id="google">
<a href="www.google.com" target="_blank">google</a>
</div>

Once the link in the is clicked it will open a blank page and load google.com but on the original page i need it to go to homepage.html or refresh either one.

You can use a Timeout for this.

HTML:

<div onclick="setTimeout(location.href='YOUR-URL-HERE';, 5000)" id="google">
<a target="_blank" href="www.google.com">google</a>
</div>

 #google{width:100px; height:200px;background-color:red;} 
  <div onclick="setTimeout(location.href='www.houjebek.nl';, 5000)" id="google"> <a href="www.google.com">google</a> </div> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM