I have a new window opened via window.open method and in that window in content I have a link with "target=_blank".
When clicked the link opens new tab in parent window instead of the one that content was in. I also noticed that for that window (created with window.open) the Ctrl+T shortcut (to open blank tab, Firefox) does not work.
I checked window.open specs and I didn't find any option that would allow this behavior.
var a = window.open("http://www.google.pl",
"Test",
"width=640,height=480,scrollbars=yes,toolbar=yes,menubar=no,location=no,resizable=yes");
a.focus();
Setting toolbar=yes makes it work in Firefox. Any idea how to make it work in chrome?
Could you show some code?
else; try with javascript:
function OpenNew(){
window.open("http://www.google.se", "_blank");
}
Rgds
Related
Close the current tab and open a new tab using JavaScript. On Chrome or any other browser.
Try this:
window.open('http://www.google.com','_blank');
window.setTimeout(function(){this.close();},1000);
Close the current tab
You can't close the current tab until and unless it has parent
reference
Its simple, if the current tab is opened by self I mean, you went to browser and typed the url in the url bar can't be closed with the javascript. Because of security reasons browsers will not allow these type of things.
If you try the following code
window.close();
you'll get following warning message by browser
Scripts may close only the windows that were opened by it.
If the tab is opened with window.open, right click on the link and opened on anchor tag then following should work
window.close();
self.close();
Opening new tab using the javascript :
window.open("https://stackoverflow.com");
I have a requirement where i want to restrict users from opening url manually from browser. The url should only open from clicking a button which opens a pop window.
Notes:-1.) I cannot temper with button code that's application's standard code
2.) I have already tried window.opener but it does not work in IE.
So basically i want to identify if the opened window is a pop window or normal browser window.
Thanks in advance.
I have this code which opens all links in my page in a new window:
<base target='_new' />
It works fine in Chrome but in IE(8) and Firefox not so. In Firefox it does open a new tab, but on a second link click it loads in the new tab but without putting this tab up front, so a user would have to click on the new tab manualy. In IE it opens a new browser window. Is there an equivalent code (..js/Jquery) to open in a new tab in all browsers?
there's no guarantee where the browser will open that new window/tab. different browsers open new windows/tabs differently, and that behavior can also be affected by browser settings.
Firefox has an option to switch to the tab immediately.
Tools -> Options -> Tabs,
"When I open a link in a new tab, switch to it immediately"
IE9 has the same option
Tools -> Internet Options -> General -> Tabs Settings
"Always switch to new tabs when they are created"
IE9 has the option of what to do with new popups.
Tools -> Internet Options -> General -> Tabs Settings
"When a popup is encountered"
- Let Internet Explorer decide ...
- Always open popups in a new tab
- Always open popups in a new window
From http://windows.microsoft.com/en-US/windows7/Tabbed-browsing-frequently-asked-questions
If you opt to let Internet Explorer decide how to display pop-ups, it
will display the pop-up in a new window if the pop-up specifies size
or display requirements. Otherwise, the pop-up is displayed in a new tab.
So the behavior is mostly left up to the user and not the developer.
You can not control this part (how to open - in tab or in window). Since this is decided by browser. More of that, you can not even rely on type of browser, since each user may select his or hers way to open new pages: always in tabs or always in new windows or some other way.
I'm not sure this applies with the "base" tag, but on links, the "target" attribute can either have one predefined keyword, or any name you want to give the new window.
The available keywords are:
_blank: opens the links in a new window or tab
_self: opens the links in the same frame as it was clicked (this is default)
_parent: opens the links in the parent frame
_top: opens the links in the full body of the window
(http://www.w3schools.com/tags/att_a_target.asp)
If you don't use one of those keywords, you can use any name you want and this name will then be used to refer to that window. This allows you to reuse a tab you opened to load a different document in it.
So by using "_new" (which is not a keyword) as the base target, you essentially say that all links must be opened in the window named "_new". At first this window does not exist, so the browser creates it (first click), and the it reuses it for all following clicks.
Use "_blank" instead so that each link opens in its own new tab.
Is there any way to force IE8 to open new window only in a pop-up? I don't want to change the browser settings. I want to open it and throw Javascript window.open(). Firefox is opening it in a new window but IE8 is opening the same in a new tab. Please suggest.
hold a SHIFT button while you click on an Internet hyperlink on your browser screen. This will force the link to open in a new window
You cannot control whether a browser opens a window in a new tab or new window.
Although, one work around is to set height and width dimension in the call to window.open() alongwith disabling the addressbar and statusbar.
window.open ("http://www.example.com", "mywindow","status=0,toolbar=0,height=600,width=900");
It worked for my case, I'm not sure if this satisfies your question.
What i want to do is when the user opens their browser and types http://xyz.com/index.html, then it should pop up a new full screen window and then display index page in that new window.
I tried with using window.open('login.html', 'new_windwo', '_self'); and it opens a new window, but then there are 2 windows — one where user typed the URL, and the 2nd that we have open in the onLoad of the first page.
I am not able to close the first window — self.close() and window.close aren’t working. I am using Firefox 3.6.
Is there is any way that I can open current page in new window, without creating duplicate?
Thanks.
No. You can't destroy a window that you didn't create with a script in the first place.