onclick 页面跳转到首页,没有任何绝对路径 [英] onclick page go to homepage without any absolute path
本文介绍了onclick 页面跳转到首页,没有任何绝对路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想点击链接,我想自己去主页上的页面
I want to click on link and I want to go to the page on home page by it self
<a onclick="javascript:GoToHomePage()" href="javascript:void(0)">Home page</a>
功能是
function GoToHomePage()
{
window.location = 'default.aspx';
}
但我想要页面的网址 www.testtest.com 而不是 www.testtest.com/default.aspx
but i want the url of page www.testtest.com instead of www.testtest.com/default.aspx
我什至不能给出像 www.testtest.com 这样的绝对路径,因为它是一个门户网站,而且同一个页面会出现在更多门户网站中.
I can't even give the absolute path like www.testtest.com as it's a portal and same page coming in few more portals.
推荐答案
以下代码将带你到'//www.testtest.com/'
following code will take you to '//www.testtest.com/'
function GoToHomePage()
{
window.location = '/';
}
这篇关于onclick 页面跳转到首页,没有任何绝对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文