如何在新选项卡JavaScript onClick =" window.location中打开div链接 [英] How do I make a div link open in a new tab Javascript onClick="window.location
问题描述
我创建了一系列社交媒体按钮,当鼠标悬停时它会切换到不同的图像(使其具有突出效果)。这些图像按照我想要的方式工作,但是,我似乎无法弄清楚如何将页面加载到新标签页/屏幕。我需要实现相当于。
假设我必须改变onClick ....中的内容吗?
这里是代码:
p> < div id =insidefooter>
< ul>
< li>
< div id =facebookstyle =cursor:pointer;的onClick =window.location的=的 https://www.facebook.com;>< / DIV>
< / li>
< li>
< div id =youtubestyle =cursor:pointer;的onClick =window.location的=的 https://www.youtube.com;>< / DIV>
< / li>
< li>
< div id =twitterstyle =cursor:pointer;的onClick =window.location的=的 https://twitter.com/;>< / DIV>
< / li>
< / ul>
< / div>
这里是CSS:
#facebook {
height:40px;
职位:亲属;
top:0px;
left:260px;
width:40px;
background-image:url(/img/index/footer/facebook-button.jpg);
}
#facebook:hover {
height:40px;
width:40px;
background-image:url(/img/index/footer/facebook-button2.jpg);
top:0;
left:260px;
width:40px;
职位:亲属;
}
#youtube {
height:40px;
职位:亲属;
top:-62px;
left:360px;
width:40px;
background-image:url(/img/index/footer/youtube-button.jpg);
}
#youtube:hover {
height:40px;
width:40px;
background-image:url(/img/index/footer/youtube-button2.jpg);
top:-62px;
left:360px;
width:40px;
职位:亲属;
我遗漏了一些CSS代码以使它更简单,但这里是一个演示 http://fiddle.jshell.net/3Bsyd/2/
谢谢!
I created a range of social media buttons which when the mouse hovers it switches to a different image (giving it a highlight effect). The images work as I want them to, however, I can't seem to figure out how to load the page into a new tab/screen. I need to implement the equivalent of .
Assuming I have to change something in the onClick.... ?
Here is code:
<div id="insidefooter">
<ul>
<li>
<div id="facebook" style="cursor:pointer;" onClick="window.location='https://www.facebook.com';"></div>
</li>
<li>
<div id="youtube" style="cursor:pointer;" onClick="window.location='https://www.youtube.com';"></div>
</li>
<li>
<div id="twitter" style="cursor:pointer;" onClick="window.location='https://twitter.com/';"></div>
</li>
</ul>
</div>
Here is CSS:
#facebook {
height: 40px;
position: relative;
top: 0px;
left: 260px;
width: 40px;
background-image:url(/img/index/footer/facebook-button.jpg);
}
#facebook:hover {
height: 40px;
width: 40px;
background-image:url(/img/index/footer/facebook-button2.jpg);
top: 0;
left: 260px;
width: 40px;
position: relative;
}
#youtube {
height: 40px;
position: relative;
top: -62px;
left: 360px;
width: 40px;
background-image:url(/img/index/footer/youtube-button.jpg);
}
#youtube:hover {
height: 40px;
width: 40px;
background-image:url(/img/index/footer/youtube-button2.jpg);
top: -62px;
left: 360px;
width: 40px;
position: relative;
I left out some CSS code to make it simpler, but here is a demo http://fiddle.jshell.net/3Bsyd/2/
Thank you!
onclick="window.open('http://google.pl', '_blank');"
这篇关于如何在新选项卡JavaScript onClick =" window.location中打开div链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!