我熟悉 html/css 导航编码。但我似乎无法获得我的客户菜单导航中的链接之一以重定向到她的博客。我知道在 html 中你可以使用 target="_blank"。但我似乎无法弄清楚如何在 javascript 中重定向。
这是我的菜单 html:
<div id="menu">
<script>setMenuOption('home');</script>
</div>
这是javascript:
function setMenuOption(pageID) {
if (pageID == 'home') {
reset();
return;
}
if (pageID == 'about') {
document.write("<a href='index.html'>HOME</a>");
document.write("<a class='active'>ABOUT AVP</a>");
document.write("<a href='services.html'>SERVICES</a>");
document.write("<a href='affiliates.html'>AFFILIATES</a>");
document.write("<a href='gallery.html'>GALLERY</a>");
document.write("<like href='whatsnew.html'>WHAT'S NEW</a>");
document.write("<a href='contact.html'>CONTACT</a>");
}
if (pageID == 'services') {
document.write("<a href='index.html'>HOME</a>");
document.write("<a href='about.html'>ABOUT AVP</a>");
document.write("<a class='active'>SERVICES</a>");
document.write("<a href='affiliates.html'>AFFILIATES</a>");
document.write("<a href='gallery.html'>GALLERY</a>");
document.write("<a href='whatsnew.html'>WHAT'S NEW</a>");
document.write("<a href='contact.html'>CONTACT</a>");
}
if (pageID == 'affiliates') {
document.write("<a href='index.html'>HOME</a>");
document.write("<a href='about.html'>ABOUT AVP</a>");
document.write("<a href='services.html'>SERVICES</a>");
document.write("<a class='active'>AFFILIATES</a>");
document.write("<a href='gallery.html'>GALLERY</a>");
document.write("<a href='whatsnew.html'>WHAT'S NEW</a>");
document.write("<a href='contact.html'>CONTACT</a>");
}
if (pageID == 'gallery') {
document.write("<a href='index.html'>HOME</a>");
document.write("<a href='about.html'>ABOUT AVP</a>");
document.write("<a href='services.html'>SERVICES</a>");
document.write("<a href='affiliates.html'>AFFILIATES</a>");
document.write("<a class='active'>GALLERY</a>");
document.write("<a href='whatsnew.html'>WHAT'S NEW</a>");
document.write("<a href='contact.html'>CONTACT</a>");
}
if (pageID == 'whatsnew') {
document.write("<a href='index.html'>HOME</a>");
document.write("<a href='about.html'>ABOUT AVP</a>");
document.write("<a href='services.html'>SERVICES</a>");
document.write("<a href='affiliates.html'>AFFILIATES</a>");
document.write("<a href='gallery.html'>GALLERY</a>");
document.write("<a class='active'>WHAT'S NEW</a>");
document.write("<a href='contact.html'>CONTACT</a>");
}
if (pageID == 'contact') {
document.write("<a href='index.html'>HOME</a>");
document.write("<a href='about.html'>ABOUT AVP</a>");
document.write("<a href='services.html'>SERVICES</a>");
document.write("<a href='affiliates.html'>AFFILIATES</a>");
document.write("<a href='gallery.html'>GALLERY</a>");
document.write("<a href='whatsnew.html'>WHAT'S NEW</a>");
document.write("<a class='active'>CONTACT</a>");
}
if (pageID == 'footer') {
document.write("<a href='index.html'>HOME</a>");
document.write("<a href='about.html'>ABOUT AVP</a>");
document.write("<a href='services.html'>SERVICES</a>");
document.write("<a href='affiliates.html'>AFFILIATES</a>");
document.write("<a href='gallery.html'>GALLERY</a>");
document.write("<a href='whatsnew.html'>WHAT'S NEW</a>");
document.write("<a href='contact.html'>CONTACT</a>");
}
}
function reset() {
document.write("<a href='about.html'>ABOUT AVP</a>");
document.write("<a href='services.html'>SERVICES</a>");
document.write("<a href='affiliates.html'>AFFILIATES</a>");
document.write("<a href='gallery.html'>GALLERY</a>");
document.write("<a href='whatsnew.html'>WHAT'S NEW</a>");
document.write("<a href='contact.html'>CONTACT</a>");
}
我正在尝试将“whatsnew”页面重定向到我的客户博客... https://ashleyvictoriaproductions.wordpress.com/ .
我该怎么做呢?
最佳答案
试过这个吗?
document.write("<a href='https://ashleyvictoriaproductions.wordpress.com/' target='_blank'>WHAT'S NEW</a>");
关于Javascript 菜单 - 如何将链接重定向到另一个网页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30264422/