Reputation: 21
How to clear address bar (url
) after chrome.tabs.update
?
I use
chrome.tabs.onCreated.addListener(function(taba) {
chrome.tabs.update( { "url": "http://site.ru"} );
});
But I need clear address bar in Chrome, after page is loaded.
Manifest:
{
"web_accessible_resources": ["icons/", "icons/icon-18.png", "icons/icon-64.png", "icons/Thumbs.db"],
"browser_action": {
"default_icon": {
"19": "icons/icon-64.png",
"38": "icons/icon-18.png"
},
"default_title": "site"},
"name": "site.ru",
"icons": {"128": "icons/icon-64.png"},
"manifest_version": 2,
"version": "2.0",
"background": {
"page": "index.html"
},
"permissions": [ "cookies","contextMenus","tabs","webRequest","storage", "http://*/*", "https://*/*"],
"description": "site.ru"
}
Must be another way. I want loading some url, when this is new tab, but in address bar field must be empty. Any thinks?
Upvotes: 2
Views: 1885
Reputation: 3106
The chrome.tabs.update
method can receive a callback function. In that callback function you can call a chrome.tabs.executeScript
to inject a script into the page.
That script can use the History API
to change the url and not trigger a reload.
If you have set permissions in the manifest
than you can modify it.
chrome.tabs.update({'url': 'http://chromium.org'}, function(tab) {
chrome.tabs.executeScript({
code: 'history.replaceState({}, "", " ");'
});
});
Upvotes: 1