admin管理员组文章数量:1287838
I have a div and inside that div I have my site logo etc...
I want that when the user clicks the site logo (my div) it will redirect him to the homepage.
How do I do it? (div onlick??)
I have a div and inside that div I have my site logo etc...
I want that when the user clicks the site logo (my div) it will redirect him to the homepage.
How do I do it? (div onlick??)
Share Improve this question asked Jan 26, 2011 at 14:44 Or BetzalelOr Betzalel 2,59712 gold badges49 silver badges74 bronze badges 3- can you please share some code so we can detail how to acplish this? – KJYe.Name Commented Jan 26, 2011 at 14:46
- 1 is it refresh or redirect? either way just make your logo image inside hyperlink, <a> tag, with href to the URL of your desire – Kris Ivanov Commented Jan 26, 2011 at 14:50
-
1
Why don't you just keep it simple, and use an
a
tag with a link to your homepage? – gen_Eric Commented Jan 26, 2011 at 14:50
6 Answers
Reset to default 7<div onclick="window.location.href = '/';">...</div>
replace '/' with your URL or URI.
<div onclick="window.location='http://www.google.';" style="cursor:pointer;">Content...</div>
Replace http://www.google.
with the relative path to your site's root. The style tag just switches the cursor to a pointer so user's know it's clickable.
<img src="logo" onclick="window.location('myHomePage');">
<div onclick="window.location('myHomePage');">stuff inside the div</div>
you can also change the window.location for a window.refresh(); if you want to refresh the page.
Will an anchor tag work for this (I don't know what your HTML is like, etc.). It will be more semantically correct and will not require javascript. I don't think there are any browsers that object to DIV
elements inside A
elements.
http://jsfiddle/4s87y/
<a href="http://www.google.">
<div style="height: 100px; background-color: #ffcccc;">
This is a test. Woohoo!
</div>
</a>
one way is to use: onclick="function(){ location.href = 'http://www.yoursite.'; }"
another one is to put the div
with site logo inside an anchor tag like <a href="yoursite."><div>sitelogo</div></a>
If you want it for OnClick then use it like this
<div OnClick="window.location=http://example.">Your Content and Logo</div>
本文标签: cRefresh Page On Div ClickStack Overflow
版权声明:本文标题:c# - Refresh Page On Div Click - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741324446a2372393.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论