admin管理员组文章数量:1023772
I am writing a chrome extension that change part of the url in the current tab and reload the page with the modified url. I am wondering if there is a Javascript equivalent of the php's parse_url function. Currently, I have to write my own parser with regex to extract parts of the url; however, I would think that such function already exists in the in Javascript.
After researching for a bit, I believe I can get a location object with "window.location" and extracts the different ponents with "window.location.protocal" etc...
In chrome extension, however, calls to "window.location" would to return a url which I believe refers to the internal ponent of chrome instead of the page's url. Assuming I that get a reference to the "tab" object in chrome, I can access the tab's url string with tab.url. Since tab.url is just a string, I am hoping there is an internal method that can dissect the url for me instead of writing a custom function.
Thank you
I am writing a chrome extension that change part of the url in the current tab and reload the page with the modified url. I am wondering if there is a Javascript equivalent of the php's parse_url function. Currently, I have to write my own parser with regex to extract parts of the url; however, I would think that such function already exists in the in Javascript.
After researching for a bit, I believe I can get a location object with "window.location" and extracts the different ponents with "window.location.protocal" etc...
In chrome extension, however, calls to "window.location" would to return a url which I believe refers to the internal ponent of chrome instead of the page's url. Assuming I that get a reference to the "tab" object in chrome, I can access the tab's url string with tab.url. Since tab.url is just a string, I am hoping there is an internal method that can dissect the url for me instead of writing a custom function.
Thank you
Share Improve this question edited Jul 5, 2012 at 9:45 Brett Zamir 14.4k7 gold badges57 silver badges83 bronze badges asked Apr 26, 2010 at 21:13 defoodefoo 5,31711 gold badges36 silver badges39 bronze badges 1- Why the google-chrome-extention tag ?! – nc3b Commented Apr 26, 2010 at 21:16
2 Answers
Reset to default 7http://phpjs/functions/parse_url:485
In content scripts of chrome externsion window.location
refers to page url
I am writing a chrome extension that change part of the url in the current tab and reload the page with the modified url. I am wondering if there is a Javascript equivalent of the php's parse_url function. Currently, I have to write my own parser with regex to extract parts of the url; however, I would think that such function already exists in the in Javascript.
After researching for a bit, I believe I can get a location object with "window.location" and extracts the different ponents with "window.location.protocal" etc...
In chrome extension, however, calls to "window.location" would to return a url which I believe refers to the internal ponent of chrome instead of the page's url. Assuming I that get a reference to the "tab" object in chrome, I can access the tab's url string with tab.url. Since tab.url is just a string, I am hoping there is an internal method that can dissect the url for me instead of writing a custom function.
Thank you
I am writing a chrome extension that change part of the url in the current tab and reload the page with the modified url. I am wondering if there is a Javascript equivalent of the php's parse_url function. Currently, I have to write my own parser with regex to extract parts of the url; however, I would think that such function already exists in the in Javascript.
After researching for a bit, I believe I can get a location object with "window.location" and extracts the different ponents with "window.location.protocal" etc...
In chrome extension, however, calls to "window.location" would to return a url which I believe refers to the internal ponent of chrome instead of the page's url. Assuming I that get a reference to the "tab" object in chrome, I can access the tab's url string with tab.url. Since tab.url is just a string, I am hoping there is an internal method that can dissect the url for me instead of writing a custom function.
Thank you
Share Improve this question edited Jul 5, 2012 at 9:45 Brett Zamir 14.4k7 gold badges57 silver badges83 bronze badges asked Apr 26, 2010 at 21:13 defoodefoo 5,31711 gold badges36 silver badges39 bronze badges 1- Why the google-chrome-extention tag ?! – nc3b Commented Apr 26, 2010 at 21:16
2 Answers
Reset to default 7http://phpjs/functions/parse_url:485
In content scripts of chrome externsion window.location
refers to page url
本文标签: google chrome extensionJavascript equivalent of php39s parseurlStack Overflow
版权声明:本文标题:google chrome extension - Javascript equivalent of php's parse_url - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745553423a2155737.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论