Tag: urlparsing

在javascript中创build一个新的Location对象

是否有可能在JavaScript中创build一个新的位置对象? 我有一个string的url,我想利用JavaScript已经提供了访问它的不同部分。 这里是我正在谈论的一个例子(我知道这是行不通的): var url = new window.location("http://www.example.com/some/path?name=value#anchor"); var protocol = url.protocol; var hash = url.hash; // etc etc 这样的事情是可能的,还是我本质上必须自己创build这个对象?

如何从URLstring中获取参数?

我有一个HTML表单字段$_POST["url"]有一些URLstring作为值。 示例值是: https://example.com/test/1234?email=xyz@test.com https://example.com/test/1234?basic=2&email=xyz2@test.com https://example.com/test/1234?email=xyz3@test.com https://example.com/test/1234?email=xyz4@test.com&testin=123 https://example.com/test/the-page-here/1234?someurl=key&email=xyz5@test.com 等等 我怎样才能从这些URL /值只获取email参数? 请注意,我没有从浏览器地址栏获取这些string。