If I open a new tab and navigate to chrome-extension://{ext_id}/options.html by typing directly into the address bar the page shows up in the list when I do
chrome.extension.getViews({'tab'})
This is the expected behaviour.
If I [right click] on my extensions "browser_action" action and select "Options" this brings up a new tab with chrome-extension://{ext_id}/options.html as the URL and it shows up in the list when I do
chrome.extension.getViews({'tab'})
Again, this is the expected behavior.
If I click a link on my extensions popup, that navigates to the options page, this opens up a new tab and navigates me to chrome-extension://{ext_id}/options.html. This is the expected behavior.
BUT, there is always a but, for some reason this page does NOT show up in
chrome.extension.getViews({'tab'})
Even though it is obviously within the context and protocol of the extension. I just don't know what the difference between the FIRST and the LAST scenario is. If anything I would expect the first scenario to fail since the user is manually navigating there, rather than a extensions own popup navigating to the extensions own options page.
I have tried using both
<a href="options.html" target="_blank">
/* and */
<a id="options" target="_blank">
<script>
document.getElementById('options').href = chrome.extension.getURL('options.html');
</script>
/* This correctly sets the href as chrome-extension://{ext_id}/options.html */
but again the same problem. The extension still runs all its Javascript correctly. I still am able to use chrome.extension functionality correctly. Just the page is not showing up within getViews. I suspect it is a Sandboxing issue, but I can't understand it working for all other situations expect one.
Does anyone know how to either get it to work correctly? or open up the page in a different manner so it will work?
PS: I do not wish to open up the options page within the popup window. I have tested this, and it STILL does not list the page within the getViews but I presume this is because it is no longer a 'tab' but a 'popup'.. But again, its not the behavior I wish.
If it looks like a bug and feels like a bug, then it is probably a bug. In the future, if you think that you're experiencing a bug, don't hesitate reporting it on Chromium's bug tracker at http://crbug.com/new.
I have reported your bug as https://code.google.com/p/chromium/issues/detail?id=341459.
A work-around to get your extension page opened from the popup window to show up in chrome.extensions.getView({type: 'tab'}) is to open the tab using chrome.tabs.create:
chrome.tabs.create({
url: 'options.html'
});
Related
I use a userscript to modify the client-side code of a website. This code is adding an anchor tag to the page. Its target is _blank. The thing is that if I click this link too frequently, the site errors. A simple refresh on the new tab fixes the problem.
When I click on the link and it instantly opens a new tab. But I don't want that new tab to render until I visit it, or with some sort of time delay. Is there a way of achieving this?
I am using Firefox, so Firefox-only solutions are fine. I found this, but I don't see a way of using it to prevent the tab from rendering in the first place. When I Google for this, I see results about add-ons that can solve the problem. But, the links to them always 404. Ideally, the solution would only affect the tabs created by this script instead of the way all tabs work, but if the only way to do it is to affect the way all tabs work, I'd accept that as a solution.
The Tampermonkey documentation says there is a GM_openInTab function. It has a parameter called loadInBackground, but it only decides if the new tab is focused when you click the link.
If there is a way of making this new tab render some HTML of my choosing, I think that would be a neat solution. i.e., I'd write some HTML that, on focus, goes to the actual website's page. If this is an option, I'd need to know how to open a tab to HTML of my choosing in grease monkey.
(Just realization of idea you told in your question yourself)
You can place simple page that waits for focus and then redirects to what you pass in URL parameter somewhere and open in background tabs. Like:
load-url-from-search-on-focus.html?http://example.com:
<!doctype html>
<body
onload="document.title=u=location.search.slice(1)"
onfocus="u?document.location.replace(u):document.write('?search missing')">
Try it.
(data:uri could have been used instead of hosted page, if there weren't those pesky security precautions blocking rendering of top-level datauri navigations :|)
For a project I need to be able to pull data from a minimized tab that displays the Instagram website. Everything works except for the "minimized" part. As soon as the window is minimized, and I refresh the page, there is no image data coming in. This is why I think it is necessary to "trick" the website into thinking that it's onscreen in order for it to load data.
Steps to reproduce:
open https://www.instagram.com/
right-click > Inspect (Developer Tools, please undock for windowed mode)
confirm that the _4rbun elements contain a srcset with the images
minimize Instagram tab
in the console, type location.reload() to reload the page
in dev tools, confirm that there are 0 or 1 _4rbun elements which however don't contain a picture
open the minimized tab
confirm that there are numerous _4rbun elements which all contain links in their srcsets
Similar behavior can be found in the /explore path except that this, on the contrary, at least contains links to the pages displaying the image (but still no direct link to the .jpg)
Is there anything i can do about this? Other websites use things like Store.js to keep track of their data but I couldn't find anything like this in the website's window object so either going the "hacky" focus way or the much cleaner "Store"-kind of way would be fine.
What I've tried was to override hasFocus like the following document.hasFocus = function(){return true}; which does keep the value on true but doesn't seem to affect the website's behavior at all. And I have tried finding an object carrying links etc. but this has been unsuccessful so far, too.
I run a web page in iPhone Safari. The page has a button. on clicking it, will show an alert message box. This is OK. Then, I change or add # hash URL by typing in the address bar, then, alert message box stop working. I click the button, and nothing happens. No javascript error but no alert message box.
Is this iOS Safari known issue?
Please share your thoughts and the solution you have come up with. Many Thanks!
$(".button").click(function () {
alert('Hello');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script>
<input class="button" type="button" value="alert" />
Note:
This is not quite due to my code. I have also tested at
Here
I have tested in the most recent iOS versions.
Javascript itself is working
Not JQuery issue, plain JS code also does not work
An alert box is working in iPhone Chrome or other browsers
Could be related to Alert, confirm, and prompt not working after using History API on Safari, iOS and https://forums.developer.apple.com/thread/65054
It seems that alert() becomes undefined. A suggested workaround is to use custom popups instead.
Never used a # inside a url other than as a reference to an anchor, but i'm not 100% sure about this...
I think that adding a # to the url and pressing enter won't reload the page. The #abc in the url does tell the browser to jump to an anchor named abc and so this will never reload the page or trigger some javascript. If you don't want to jump/scroll to some anchor insite your actual page, don't use # within the url. That should solve your problem.
The # in a url is a fragment identifier. It is expecting something to be after the url example: www.yourpage.com/foo.html#bar. This leaves it looking for the bar fragment in your page. The page will not be reloaded.
This might help w3 fragments
Well, this might be due to the fact that you're not making another http request and instead instructing the browser to go to that said hash of (an example) #abc.
If you had an element of some sorts like this with that id, it would jump to that section of the page.
Example:
click to jump down to my section
<p id="abc">my section</p>
I'm assuming when you type #abc in the url, it will be looking for that. Which isn't there, of course.
Other than that, I'm not entirely sure.
ASP.Net Webforms pages are wrapped in a massive form, which restricts other forms on the page because nested forms don't work. This is intentional because in a webforms project, there can only be one form per page, and all of the server/client interaction require it. In order to build a custom form, I put together a modal dialog in this way. In order to allow for proper error messages from the server, my modal dialog has to post back to itself. In order to do this, I followed this trick to use the form target as the name of the window the dialog is in.
The problem comes when I try to add a button to download a file. When I try to download a file from this dialog now, nothing happens. I can redirect my response to the file in question, but I can't write the file to the response because the dialog box just sits there when I click the button and nothing happens.
After quite some time researching and building a small test case, I found out that there are several interesting factors here.
Response.WriteFile() works fine in webforms, even when the form is set with a target of the current window.
Modal dialogs can download files perfectly fine, unless the form is set to the target of the current window.
Through extensive testing, this appears to be an obscure bug, or perhaps even a strange attempt at security. This also appears to be specific to IE 8, though I didn't get to test other versions of IE.
The trick to allowing the download inside the modal dialog is to change the form's target.
function downloader() {
document.getElementById("form1").target = "_blank";
}
This fixes the IE bug and appears to work in all other browsers (though I couldn't get opera to show the pop up at all, even with "allow all popups").
Thought my day of toiling shouldn't go to waste and maybe this will help someone else in the future.
I've written a simple bookmarklet that opens multiple web pages with a single click:
javascript:(function(){window.open("http://www.w3schools.com");window.open("http://www.google.com");window.open("http://www.yahoo.com");})();
I wan't to be able to open the browser and click this immediately, but the bookmarklet won't work unless a page is already loaded in the window. I prefer to have my browser home page set to "Blank" for speed. Is there a way to make this bookmarklet execute without a page already loaded?
Also, I'd like the bookmarklet to replace whatever page is loaded in the window, if something is indeed loaded. At present, it opens 3 new tabs. I've tried the "_self" and "_parent" values for the "name" attribute on the first window.open, but it doesn't seem to work. I may not be formatting it correctly.
Any help is appreciated! Thanks!
It isn't possible to open bookmarklet in no page.
Instead, you can try to set your homepage to something like data:text/html,Welcome! (yes, it IS a working URL).
To open a page in the same tab, type:
location.href='http://www.w3schools.com'
I was having the same problem, and learned from the internet that if you go to your about:config, search for browser.newtab.url and change it to about:blank instead of the default about:newtab your javascript bookmarklets should work (just tried, and it's working!). This should be cleaner than doing a data:text/html message (in any case even if you set the homepage it doesn't work for every new tab, only once for a new window)