How to Get the Url of Currently Opened Tabs in All Browsers With PHP or JavaScript

Retrieving which tabs are open in Chrome?

Yes, here is how you can do this:

Note: this requires permission "tabs" to be specified in your manifest file.

chrome.windows.getAll({populate:true}, getAllOpenWindows);

function getAllOpenWindows(winData) {

var tabs = [];
for (var i in winData) {
if (winData[i].focused === true) {
var winTabs = winData[i].tabs;
var totTabs = winTabs.length;
for (var j=0; j<totTabs;j++) {
tabs.push(winTabs[j].url);
}
}
}
console.log(tabs);
}

In this example I am just adding tab url as you asked in an array but each "tab" object contains a lot more information. Url will be the full URL you can apply some regular expression to extract the domain names from the URL.

php javascript update a div in all opened tabs of a site in browser

I have done this with AJAX and works fine, updating on all pages when database has changes, whatever page is opened in multiple tabs of a browser.

$(document).ready(function(){

var currentData = "";
function auto_load(){
$.ajax({
type: 'POST',
url: 'menu_update_total_items.php',
success: function(data){
if(currentData != data) {
$('.summary12').html(data);
currentData = data;
}
}
});
}
auto_load();
setInterval(auto_load,1000);

});

how to find particular site is already open or not in the browser?

There is no way to run any client side code in an HTML formatted email. So this is impossible.

The closest you could come would be to:

  1. use some kind of token to identify a user (e.g. stored in a cookie)
  2. run some heart beat code to see if they are still on the page (e.g. use XMLHttpRequest to request a 1 byte file every 15 seconds using a page id generated when the page was loaded and the user id in the cookie)
  3. check on the server to see if a heart beat from a different page was received recently when a new copy of the page is loaded
  4. serve different content if it is

How to get browser's current page URL from iframe?

You probably don’t need the “actual URL”, but only the page id, I assume …? That you can get by decoding the signed_request parameter that gets POSTed to your app on initial load into the iframe.

How to “decode” it is described here, https://developers.facebook.com/docs/facebook-login/using-login-with-games#parsingsr

If you’re using the PHP SDK, that has a method already that does this for you.

How to fetch URL of current Tab in my chrome extension using javascript

Note you must have the tabs permission set in your manifest file

"permissions": [
"tabs"
],

http://developer.chrome.com/extensions/tabs.html

or the activeTab permission if initiated by a click on the extension button[Xan]

https://developer.chrome.com/extensions/activeTab


Code:

chrome.tabs.query({currentWindow: true, active: true}, function(tabs){
console.log(tabs[0].url);
});


Related Topics



Leave a reply



Submit