获取特定标签的网址? [英] Get URL of a specific tab?

查看:103
本文介绍了获取特定标签的网址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在谷歌浏览器中,我将如何获得在特定选项卡上显示的网页的网址?

这取决于关于如何定义特定标签。有很多功能可以获取标签,然后又可以返回标签对象。这个对象有一个url属性。



让我们以当前选中的标签为例。您可以通过 chrome.tabs.getSelected 获得相应处理。其中 null 是一个WindowID,并且默认为当前窗口。

  chrome.tabs.getSelected(null,function(tab){
alert(tab.url);
})

有关更多信息,我建议您查看文档的API


In Google Chrome, how would I get the URL of the page being shown on a specific tab?

解决方案

This depends on how you define specific tab. There are numerous functions to get a tab, which in turn give you back a Tab object. This object has a url attribute.

Let's take the current selected tab for example. You get a handle on it with chrome.tabs.getSelected. Where null is a WindowID, and defaults to the current window.

chrome.tabs.getSelected(null, function(tab) { 
    alert(tab.url);
})

For more information I suggest you have a look at the documentation of the API.

这篇关于获取特定标签的网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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