I am trying to implement a pop-up window similar to how Origin (click on the 'Log In' does it (pops up in another window with a specific size). I've tried going through their code but I cannot find out how they are doing it. I tried Googling this issue and someone said to use window.open, but I cannot find on the Origin website any reference to this code. I've also noticed that the when viewing the Origin website on IE, clicking the 'Log In' link will open the page in the same window as oppose to popping up another window. Is there some sort of IE detection going on? Why would Origin do that only for IE?
They could be using window.open in an external JS file. Basically, they use that to open up a login page and saves all the login stuff in what is called PHP Sessions.
It might not work in IE because IE doesn't support a lot of the newer technologies that are being used right now. Honestly, it's better to make the login page on the same window, because some browsers might disable popups, or some users might just find popup windows annoying.
something like this?
window.open('your page location', 'pop out window's title', 'width=850px,height=600px,top=200px,left=400px,toolbars=no,scrollbars=yes,status=no,resizable=yes');
Related
I have a requirement where a few users are required to keep a watch over a dashboard browser page.
My first thought was use some javascript magic that reloads the page, switches to it if it is not active and being the browser window to front. I quickly realized how difficult this (accept for reload) is and that browsers do everything possible to prevent it, with good reason.
On the other hand, I have err, seen some "websites" which show a pop-up telling me that my browser is affected and I need to call the given 800 number. These pop-ups are pretty much impossible to kill. I could use that if I knew how.
I have also considered utilities like ergociser which sit in the taskbar and open a browser window periodically. This could work but it opens a new pop-up window every time, while I am keen to reload it in the same window.
The closest I have come so far is to use alert which does not bring the window to front but it does flash the taskbar.
I am thinking of a chrome extension or firefox add-on that brings named pop-up tab. But I am open to any other ideas. It can be a browser specific solution, and it is ok to require white-listing in pop-up blockers
What is a best way to do this?
UPDATE
There are two close votes for "Too Broad". It is true that I am looking for the right technology to use for this problem, so I cannot refine it with technology-specific details. But short of that, appreciate if someone can give suggestion for narrowing down the problem statement.
Just like the title says, I'm wondering whether it's possible to detect when I click on "Background Page" for my test plugin on the "chrome://extensions/" page.
Right now when I open the background page, the console is undocked. I saw this post and found ways to make it work inside each content script. But is there a way to make the plugin detect it's own console opening?
This function from that post inside my background.js doesn't seem to detect anything.
chrome.tabs.query({url:'chrome-devtools://*/*'}, function(tabs){
if (tabs.length > 0){
console.log('opened');
}
});
Any advice would be highly appreciated.
Devtools windows are not visible to tabs/windows APIs anymore.
This has changed since the answer from '14 was posted - therefore this method no longer applies.
Unfortunately, I can't find a link to the Chromium issue that implemented that.
When i open a new window using window.open javascript, chrome opens with about:blank, but firefox opens with jsfiddle back url and if you right click on the page, you can still see the page loading. You will not see the refresh icon, instead a stop icon is appearing.
I need to open the new window with about:blank.
Here is the jsFIDDLE
Tested with Chrome 45.0
Tested with Firefox 41.1
<button id="helper">Click here for help</button>
What you are experiencing is a new Firefox behavior that passed in version 40 or 41 (sorry I did not find the reference).
Expect it to become part of google's behavior soon too, you can see people requesting it already(Chrome issue)
Unfortunately there is not much that can be done for now as it is brand new people have not found workaround or even if it is a good idea to fight against the browser... My suggestion is to not use about:blank at all and use a blank html page from your domain, that would make things easier on the users.
Instead of about:blank take #:
$("#helper").click(function(){
windowURL = window.open("#","Looking ....
EDIT
in order to prevent the browser from showing an "infinite loading", close the document:
...
openedDocument.open();
openedDocument.write(myHTML)
openedDocument.close()
I want to create elements which (when clicked) will guide visitors towards two differenct websites (both in new windows). How can I do this? Below are the two ways which I tried, which both do not work as only one page/ window is opened. Thanks in advance!
Timo
The solution as suggested here: How to make a link open multiple pages when clicked . But maybe the solution is outdated, but for me only the first webpage is openend (with all the indicated solutions. (for example the code which is suggested there)
HTML Click Here
$('a.yourlink').click(function(e) {
e.preventDefault();
window.open('https://www.youtube.com/watch?v=H9XIXFwpyEc');
window.open('https://stackoverflow.com/search?q=open+multiple+pages');
});
While both using a class and an id with both a different a href and both with the extra options of opening new window also does not work as it only opens the first window
HTML Click Here
$('.yourlink').html(''); // Add page
$('.yourlink a').attr('target', '_blank');// Make sure it opens in new window
$('#extra').html(''); // Add page
$('#extra a').attr('target', '_blank');// Make sure it opens in new window
Using Chrome, I'm not seeing the problem you describe. But when I tested it in IE, I suddenly got a "popup blocked" message.
It's not strange though. I'd hate it if a single click on a link could suddenly spawn 10 new windows. In this scenario I actually think IE handles it better (by blocking the second window).
The thing is that window.open will only work if the action that invokes it is a trusted event. That usually means a user-initiated event, like click. But what Chrome doesn't account for (I assume) is that a single trusted event can then invoke several window.open.
I've tried to work around this feature, but have not (yet) been able to fool IE. The options, as I see it, are:
Ask users to add your site to the popup exceptions (internet settings).
Spawn the pages in iframes within your own site
Ask users to use another browser ;)
Or the obvious:
Use separate links for the windows
I'm brand new to StackOverflow and userscripts, and I'm trying to get a fresh start!
Worthless information aside, I'm having a bit of trouble with a tiny script I recently whipped up.
(function () {
$("#enbut").click();
setTimeout(function () {
open(location, '_self');
window.close();
}, 100);
})();
What it does is clicks a button, waits a second for the website to register that I've clicked it, and then it closes the webpage.
The only issue that I am having is that it does not seem to want to close the webpage when the tab isn't the one I currently have active (Opened up so I can see it).
The script works fine if I open the webpage directly, but if I right click and open in a new tab, it's able to click the button, but the page doesn't close until I open up the tab.
Is there any reason this would be happening, or any way to fix it?
I'm using Chrome, so maybe it's just a browser security feature like what they have done with closing windows?
window.close(); throws a security issue when used as a general userscript in today's browsers. Even when using the work around ( open(location, '_self'); ), it does not seem to allow it in tabs that are not the active window.
In order to resolve this, I had to convert the userscript to a Chrome Extension, which gives the script full control over Chrome's security measures. I don't think there would be any other way to get this working as a plain userscript without messing with Chrome's internals, which would be a stupid thing to do for a simple script.
Thanks for the help, guys!