获取子域名并使用greasemonkey将其加载到URL [英] Get subdomain and load it to url with greasemonkey

查看:74
本文介绍了获取子域名并使用greasemonkey将其加载到URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有网址 http://somesubdomain.domain.com (子域名可能会有所不同,域名总是如此相同)。需要使用子域名并使用greasemonkey(例如,使用URL domain.com/some/path/here/somesubdomain打开一个新窗口,使用domain.com/some/path/here/somesubdomain)重新加载页面。

I am having the URL http://somesubdomain.domain.com (subdomains may vary, domain is always the same). Need to take subdomain and reload the page with something like domain.com/some/path/here/somesubdomain using greasemonkey (or open a new window with URL domain.com/some/path/here/somesubdomain, whatever).

推荐答案

var full = window.location.host
//window.location.host is subdomain.domain.com
var parts = full.split('.')
var sub = parts[0]
var domain = parts[1]
var type = parts[2]
//sub is 'subdomain', 'domain', type is 'com'
var newUrl = 'http://' + domain + '.' + type + '/your/other/path/' + subDomain
window.open(newUrl);

这篇关于获取子域名并使用greasemonkey将其加载到URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆