Is it possible to focus a webpage programatically using javascript? - javascript

I have a javascript extension on top of Gmail.
Say a user navigates to some other website xyz.com.
And If there is a very important update from my extension
I want to automatically navigate the user back to the Gmail form my javascript code.
Is this possible? I have tried window.focus() but it does not seem to work.
Any other suggestions please. Thanks.

Related

How can I prevent webpage reloading when a user clicks on the address bar enter using JQuery or JS

I am tying to prevent a webpage reload when the user presses enter on the address bar. Using JQuerys e.preventDefault() method in Google Chrome does not work in the beforeunload method. In general, is this possible to achieve this goal with JQuery or JS or do I need another technique?. If it is possible can someone help me to fix this?
You simply can't to do it. It is not possible to deal with address bar itself from JavaScript. You can only add the confirmation dialog.
Short answer: You can not.
Think it this way, When the user hits enter in address bar, the user is entering an URL and trying to reach that, And it is handled by the browser only. You can(and should) not block the user from leaving the page. Utmost, you can notify the user before leaving the existing page.
If you are doing this For performance optimization, consider caching the static files.

Is it possible to inject a chrome extension popup into current webpage without using react?

I'm currently working on chrome extension and I'm dealing with a content injection problem.
In my extension when user clicks the button inside the popup, he has possibility to choose DIV from the webpage he's currently on and then he can return back to popup to choose options for that chosen DIV.
The problem is that I can't force the popup to be open when user clicks outside it (actually I can with open popup console, but it's not a solution here) and the popup.html is reloading every time extension is shown to user.
So I came up with an idea that I can inject a popup into an iframe in the webpage to have control over it's behaviour but I found similar solutions only connected with chrome extensions based on react. Is it possible without any framework?
Any help would be greatly appreciated.

How to found which script is run when i click anywhere in website?

Actually, I am working on a WordPress website and I use a theme for it. The problem is that daily I open first time my website and click anywhere in the body it open google ads in new browser window like facebook, jabong and all. So how to remove that. And also after every cleaning browser cookies and history process same issue, I get. Please let me know how to fix it and how to determine what function run when I click?
Thanks in Advance.

How do I insert a button in the Gmail inbox page in Chrome?

I want to add a button/link in a Gmail inbox page in Chrome browser, like "Any.do" plugin.
If the user opens Gmail and opens any mail from the inbox, I just put the button or link in that page?
I am new to plugin concepts.
How can I achieve this?
Regards
Sanju
pretty new to chrome extensions and still figuring this all out but basically there are different types of 'extensions' that you can create for chrome. Sounds like you want to create a gmail 'gadget',
Contextual Gadgets : https://developers.google.com/gadgets/docs/gs?csw=1
if you follow the tutorials, it seems pretty straight forward.

How do I detect the Google+ "share task complete" in Javascript and close Chrome Bookmarklet?

I'm using a bookmarklet that lets me share the current URL on Google Plus.
Here's the JavaScript:
javascript:(function(){var w=480;var h=380;var x=Number((window.screen.width-w)/2);
var y=Number((window.screen.height-h)/2);
window.open('https://plusone.google.com/_/+1/confirm?hl=en&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title),'','width='+w+',height='+h+',left='+x+',top='+y+',scrollbars=no');})();
Is there a way to detect the "Sharing Successful" event and call a window.close()? And where do I call it in this JS? Even a pointer in this direction will be appreciated.
Is there a way to detect the "Sharing Successful" event and call a window.close()?
No you can't.
Browser security prevents you from using Javascript on one page to interact with another page on a different domain. This is why I can't put up a website that opens your bank's website in an iframe and then controls it.
The Javascript in a bookmarklet is considered to be part of the page that is open when you execute it. So the code becomes part of the page you are adding to Google Plus, and it can not interact with the page from Google because it is on a different domain; and vice versa. The code can open the window, but that is all.
To do what you want would require creating an add-on, extension, or user script.

Categories

Resources