Google Chrome Extension, new tab focus - javascript

I've been working on an extension for Google Chrome, this is my first attempt.
So far I've been able to run my extension in a new tab, but I wanted to know if there was any possibility to remove the focus from the omnibar/addressbar to some content in the tabbed window.
For Example, I'm implementing an input field or text area, and when a new tab opens, I want the blinking cursor/caret to originate in the said text area, and not the google omnibar.
Any possibility using jquery or any google chrome extension api?

I had the same problem. My solution was to use a "dummy html" file as the new page, and everything this page did was running the following JavaScript code (in an external JS file linked to from the dummy html file):
window.open("the-real-new-tab-page.html")
window.close()

Related

How to open a browser app which is listed in chrome://apps

Chromium-based browser has the apps page at chrome://apps
There are some apps that I have installed into it. Is it able to launch one of them from JavaScript somewhat just like opening file selecting box?
I can open chrome://apps by setting this URL in to a link, but how about a single app?
Copied from: Open Chrome in a new window (Chrome app)
Sadly, there's no way to do that I know of.
Using window.open in an app's context is a bit of a hack, but results in the URL being open in the user's default browser (not necessarily Chrome). There's no control as to how the browser chooses to open it.
There's a Chrome App-specific API that was created specifically with "open a page in Chrome" in mind, chrome.browser. However, it still doesn't provide an option to open in a new window.
The closest you can get is to create your own "browser": an app window with an in it. Then you have full control over the presentation, but it's not integrated with Chrome's profile and may require additional work to implement things like dialogs and browser controls. See the Browser sample app and documentation.
You may need the app id which you can then append to the URL. I am not entirely sure how you would find but if you go to the apps page on chrome, drag the icon of the app to the search bar in the browser, you should get the full link.
For instance, I dragged the Google Slides Icon onto the search bar and it gave me this url chrome-extension://aapocclcgogkmnckokdopfmhonfmgoek/main.html. So, you may give it a shot! Try to open the chrome apps page, then drag the app you want to open in new tab onto the search bar.
Hence, using Javascript:
window.open("chrome-extension://aapocclcgogkmnckokdopfmhonfmgoek/main.html", "_blank");
Opens Google Slides App in a new tab.

How to open a file directly from msSaveOrOpenBlob?

I am using IE 11 for web development. Now in javascript, I do window.msSaveOrOpenBlob(fileBlob), a pop up shows on the button of the page with save and open option.
Now what I want to achieve is that perform click event on open so the file will be open automatically(without user click open).
Here is the case:
User click a link, it should open the associated file with whatever file reader that can open the file. PDF, will be adobe reader, word document will be opened in microsoft word.
Things still works when I click the open button from pop up. I just want to skip this manual click and do it in the code.
I've seen some webpage does this, but can't figure out myself. Need some help.
As far as I know, we can't control the "open or save" prompt using JavaScript. It is the browser behavior.
As a workaround, to the pdf file, I suggest you could try to use the pdf.js plugin to display the pdf file. To the Office documents, you could check the following article to use the Office Web Viewer to view the document.
Office Web Viewer: View Office documents in a browser
Besides, here is an article about displaying (Show) Word, Excel, PowerPoint (PPT) and PDF files in browser web page in ASP.Net, you can also refer to it.

Google chrome extentions java script open new tab prob

I'm making an extension for google chrome that allows people put player id in a field and press snap and a new tab will be opened with the url the text that user typed.
Any idea what js codes should I use for the url text in new tab?
Edit:
What I did:
I used php instead of js
I used $_Post["name"] but there is problem too!
I need the var to appear only like the person typed it... not with key=var

How To Highlight The Text In PDF Files Through Chrome Extension

I am new to programming. I am creating a Chrome extension, which is when clicked shows a pop-up with many categories with check boxes. If you click the checkbox, the extension will interact with web page and highlight text related to selected categories.
Now my question is how to highlight the text in pdf files when I am clicking the popup page checkbox. Or how to interact with the pdf files from Chrome extension. Please help me.
I don't believe you can. The built in PDF renderer in Chrome is just a plugin. You can see that by viewing the source of the page.

Google Chrome Extension

How do I open a link in a new tab in the extension HTML.
E.g.
clicks on icon
sees Google chrome window which has the window.html
inside there are two links, one link to open a link in a new tab, other in the original tab.
I used window.location, doesn't work like that.
If the page is indeed in a google chrome extension, you can force the browser to open the page in a new tab using javascript (which you know is enabled sine you are a google chrome extension).
chrome.tabs.create({url:"http://somewhere", selected:true});
Your extension will need the tabs permission.
See: http://code.google.com/chrome/extensions/tabs.html
I don't know why this question has two upvotes, but anyway you can try using the target attribute for anchor elements.
<a target="_blank" src="http://myFancyUrl">This is a link to a new tab</a>
However, it won't open in a new tab unless the user has the navigator configured that way (usually does).

Categories