This question already has an answer here:
Communicate between scripts in the background context (background script, browser action, page action, options page, etc.)
(1 answer)
Closed 5 years ago.
How can I use data from background.js in popup?
What ways are exist to solve this problem?
You can use Message API to communicate between background, popup, content-script and ui-pages.
It is also possible through the localStorage.
Related
This question already has answers here:
disallow window open in javascript
(2 answers)
Override window.open()
(1 answer)
Closed 4 years ago.
I want to get rid of the window.open function. Is it somehow possible to override or deactivate this function?
I fact a want a browser in which the function window.open is not implemented at all. And I want a browser which is not able to load any resource which comes from another host than that one typed into address bar. (I know that many pages would not work any more in that browser.) But I know I will not get.
Sometime I visit a page that uses window.open by onclick for advertisement. I’m not against advertisement, but against unwanted pop-ups.
I want to inject those pages with my own JS to disable open().
This question already has answers here:
Javascript : Change the function of the browser's back button
(5 answers)
Closed 8 years ago.
I have a page where the content is delivered mostly though javascript. Hitting the back button would basically exit the page to wherever the user came from instead of showing the previous content. Is there a way to take manual control over what the back/forwards buttons do on a web page?
This is a classic AJAX problem - each page is loaded asynchronously with no new GET from the browser, thus no history.
Look into History API of HTML5 to programatically push page state into the browser history. Other than that you are out of luck.
This question already has answers here:
How can we open a link in private browsing mode
(2 answers)
Closed 8 years ago.
Is there a way, via Javascript or other code, to open a url in a private/incognito window from an HTML page? Ideally cross-browser or at the very least IE and Firefox.
The anticipated behaviour would be along the lines of
Link
The simplified reason for this is because admins want to be able to log in as users to preview various pages, but without logging themselves out. Whilst there are various other ways around this issue, this would be the simplest (assuming it is possible).
We can't force the visitor to view the page in an incognito/private window. Browsers provide no API that would make that possible outside of an extension.
This question already has an answer here:
Difference between background script and content script in chrome extension
(1 answer)
Closed 8 years ago.
I want to create an extension that reads all the colors of a site and change all the colors accordingly, if you click on the button.
Where should I write this code?
In a content script or in a background script?
What is actually the difference between the two?
Read the well-written Overview at the documentation. This should answer a lot of your questions.
In short, content scripts execute in an isolated context of a webpage, having access to its DOM, but have very limited Chrome API access.
A background script is usually used for central handling of tasks, while content scripts act as intermediaries between it and pages you want to interact with.
As for your situation:
You need to have a background script to listen to the button click event.
You need to have a content script to interact with a page.
So, you need both, and the background script can message the content script to do its magic.
This question already has answers here:
How to communicate between iframe and the parent site?
(7 answers)
Closed 8 years ago.
I have a question about data transfer on iframes as can be seen in the picture below
http://img703.imageshack.us/img703/143/qcvf.jpg
My main page has 2 iframe.
How can I send a data to textbox iframe_b from main page when I working iframe_a?
Thanks.
You can try to set the iframe's src with a hash, and detect hashChange within the iframe. $(window) bind hashchange how to check part hash changed?
If you want to set data into iframe in script directly, I remember, not so sure, if the src of iframe is a different host, you cannot, for security reason.