I am trying to open a new tab with javascript.
How to write it so that it would work in chrome, firefox and IE7?
(the pages are on the same domain)
UPD: Let's presume that the user uses the default configuration of IE7...
You cannot control how the browser will handle opening new popups / pages. This is entirely handled by the browser. If the user has set their browser up to open new pages/popups in a new window, you cannot force your own page to open in a tab.
Plain HTML:
click here
Javascript:
window.open("newpage.html", "_blank");
But keep in mind what psynnott said.
Related
I have a web application where I have four/five icons in the default page. On click of these icons i am redirecting to some URL in new tab of already opened chromium browser instance using javascript. Below is the javascript code snippet that I am using to launch the URL in new tab of already opened chromium browser instance. Here I am manually clicking the icon
window.open(myURL, '_blank');
But the issue is when I am trying to open the same URL using the same code and programatically triggering the same code to open the URL in new tab, it opes up as a Pop Up but not in a tab. Below is how I am trying to pragmatically open the URL. I am calling the click event of the Icon in the default page using some script rather than manually clicking the icon.
$('#myIconId').click();
If somebody could please help me out. TIA
give a try to use
content of the anchor
Although You shouldn't force user to open new pages or new tab without showing them a hint on what is going to happen before they click on the link.
Above code may or may not work on all browser, please test before making live.
UPDATE
Ref : Programmatically open new pages on Tabs
I have a program that is written in CSS/HTML/JavaScript all inline, and opened directly from the HTML file (no web URL). Right now, everyone I work with has their browser set to open any links in a new tab in the same window, which makes the program useless, as it is form that is filled out manually, meant to be on a second monitor.
Right now, I have the window.resizeTo(); and the window.moveTo(); functions working properly IF the open in tabs is changed to open links in new window, but I cant walk around doing that to over 500 computers (no exaggeration on the amount), not to mention, any changes to the settings are reset afte the computers are reset.
When I try the window.open();, it just opens up a blank page in a new window after the .html file is opened, I need it to open itself in a new window, and then resize/move after.
Use window.open(...) with the height and width parameters set. This will force the link to open in a new window:
Share Page
Demo
You can pass a URL to window.open() to open that URL.
You can pass the current URL using location.href.
You can also specify a size and location directly in the third parameter.
Opening a page on tab or a separate window is browser specify feature, and it cannot be controlled by a Web Application.
window.open() will open a popup window and can open any URL you specify when provided:
window.open('openthispage.html);
window.open(URL,name,specs,replace)
add the URL of the program and it should work
I search a lot but could not figured it out.
Is it possible to open a new window with tab enabled using window.open() method?.
The way chrome context menu "open link in new window" works.
The browser decides on its own how links will open. Sometimes a user can configure how links are to be opened, but the web page cannot do this.
using an anchor tag you can set the target attribute to have some control over where the link opens. Other than that, this behavior is up to the browser and user and cannot be controlled by javascript.
Use this code
window.open("http:.//www.google.com","DemoName",'scrollbars=1,height=650,width=1050');
I'm currently writing an extension for Chrome (the way you can integrate jQuery etc is pretty awesome, just like greasemonkey) however I have stumbled upon a problem:
I would like to open a page in a new tab without actually focusing that tab (so stay on the same page)
Thanks!
chrome.tabs.create({url: "http://...", selected: false});
If you need this in a content script where Chrome Tab API isn't available, you need to send a request to a background page.
Try to blur and focus the window.
var winPop = window.open("blah.html");
winPop.blur();
window.focus();
I am building a web app, for myself, to control some servers on my home network, and discovered what I think is very odd behavior in Firefox.
If you open a pop-up, via javascript, in Firefox, is it then impossible to open a new tab, via javascript in that pop-up? If not impossible, how do you do it?
Given a clean, default Firefox 3.6.3 installation...
If I open a page in Firefox and then call
var my_window = window.open('http://www.google.com','_blank','top=10');
A brand new "pop-up" window opens.
However, if instead I call
var my_window = window.open('http://www.google.com');
A get a new tab.
HOWEVER...
If I call the first version
var my_window = window.open('http://www.google.com','_blank','top=10');
And then in the new "pop-up" that opens, I call
var my_window = window.open('http://www.google.com');
It opens a new tab in the original window, not a new tab in the pop-up.
This seems very odd, and not intuitive at all. Why would the call in the pop-up open a tab in the "parent" window?
This behavoir is a browser setting, the user desides if he opens a new window or a new tab when he opens a link. You cannot manipulate this.
Only thing you can manipulate is if you open the link in a "blank" screen, current window or certain frame
They are both children of the original document and modal windows generally do not have children. They are the rough equivalent of modal dialogs in the Windows OS. In fact, that is what IE does; it even calls it a modal dialog. I think that what is being described here is a new browser instance and not a window with tabs.