url=require('url');
qs=require('querystring');
var http=require('http');
http.createServer(server).listen(1337, 'hostname');
function server(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write(req.url);
a=url.parse(req.url, true);
console.log(a);
res.end('\nHello World\n');
}
console.log('Server running at http://127.0.0.1:1337/');
//http://host:1337/#A=1111111 <--- not coming in log or url
//http://host:1337/?A=11111111 <--- works ok
//usecase : facebook access_token url format is something similar to above
7
A
回答
19
'#'
標記之後的部分URL(稱爲fragment
)未發送到服務器。如果將數據存儲在片段中,則由您來處理該數據,並使用GET參數中的數據執行ajax請求。
+2
Facebook使用http:// servername:port/path#access_token = somestring – 2012-04-02 05:02:59
+0
以該格式回撥dev服務器我真的希望他們沒有關閉這個問題。這個facebook片段真的很煩人。 – Gavin 2014-06-20 00:25:56
相關問題
- 1. Ember rootURL with Hash
- 2. Rails:form_for with json:undefined method to_model for Hash
- 3. RabbitMQ with nodejs
- 4. Morris js with nodejs
- 5. Selenium with PhantomJs和NodeJs
- 6. parse-server cloudCode with nodejs
- 7. Whois with NodeJS Docker Image
- 8. 示例WriteBack with nodejs
- 9. 在nodejs中使用CakePHP實現Security :: Hash
- 10. JavaScript - 如果URL沒有#hash?
- 11. Autohotkey Add Javascript Hash To Local URL
- 12. PHP:用php寫hash到url?
- 13. PHP&Hash/Fragment部分的URL
- 14. Promise not run with Mocha,in nodejs
- 15. curl with nodejs express - POST數據
- 16. groupby with org nodejs on postgresql
- 17. Mod_rewrite for url with?
- 18. Jamon with DB2 url
- 19. MVC3 url with javascript
- 20. Collapsing Toolbar with url from url?
- 21. 中的NodeJS URL
- 22. Reroute url | Nodejs | Express
- 23. Spring Back with Backbone URL
- 24. Javascript:Window.Open with#sign in URL?
- 25. If-statement with changing url
- 26. Flex:停止TabNavigator將#HASH添加到URL
- 27. JHipster - 從URL永久刪除#HASH
- 28. 做Twitter,Hash-Bang#等鏈接! URL的
- 29. 如何獲得#hash值在URL中JS
- 30. 獲取實際的URL HASH在PHP
當你請求一個像這樣的URL:http:// host:1337 /#A = 1111111它只是發送這個到服務器http://主機:1337 /和這個片段到瀏覽器#A = 1111111 Facebook在本地獲取此網址在瀏覽器中,解析它,它變成像這樣的HTTP GET一個變量://主機:1337/A = 11111111 然後使用AJAX數據請求,分析所有數據,並將其寫入了?瀏覽器。 這是一個需要'onhashchange'事件的舊技術,目前,最好的方法是實現pushState並更改整個URL而不刷新頁面。 – neojp 2012-07-26 21:22:04