I want to open a link in a new tab, equivalent to the: target=_blank"
But instead of opening a new tab/window, which in my case can result in the user (old people that are bad with tech) not knowing that a new window opened, I want to open a smaller window, on top of the current window/page. This is so that the user sees the new window easily.
Is there a nice way to do this?
This can either be in code behind, or client code, it doesn't matter for me
<script type="text/javascript">
// Add this on the page that will open up.
alert('New window opened!');
</script>
How about a simple alert?
Related
What I am doing is sending a user a link to a page but I want to close that page once the user submits the form.
To do this I have to open a new window for the user
//this always opens a new tab not a new window
open in new window
after the user opens the link I don't want to close his/her browser (from where the user opened the link). All i am sending is the link in a e-mail.
This is not something you have any control over.
Given a target attribute indicating that a new browsing context should be opened, the choice between opening a new tab or a new window is a user preference and not under the control of the page author.
If you were using JavaScript, then you could specify the dimensions of the window using window.open() and a side effect of that would be to trigger a new window instead of a new tab. Since you are working in an email, that isn't an option. Email clients strip JavaScript from HTML formatted emails.
I want to give my users the option of opening a tab into its own window rather than merely switching the current window’s display to that tab. I have lots of tabs in my app, and the user often wants to study a few of those over long periods of time. For example, the user may watch charts being updated over time via Push.
Currently I add an "Open Window" button to a tab's layout. This opens a new browser window with the current tab’s layout.
Is there any other way to do this? A context-menu on the tab itself? User holding down a keyboard modifier (Control key, Command key, Option/Alt key) while clicking the tab?
Actually, there is one trick:
tabSheet.setCloseHandler((tabsheet, tabContent) -> {/** make new window **/});
Of course it works if tabSheet is closeable.
So if anybody click close button then you could do your own logic - in this example open new window.
But it could be misleading. To handle this problem you could replace close caption from x to any other more meaningful sign.
For example, look at Valo TabSheet demo. If you look in HTML code, than you notice something like this:
<span class="v-tabsheet-caption-close" aria-hidden="true" aria-disabled="true">×</span>
I think you are able to change this x using for example JavaScript.
I have a web page where people can go and design things, let's say furniture layout. There are buttons on the page to save the work, but I don't have any protection if someone just goes up and puts a new URL in the Address bar. Then the browser (say Chrome 34.0) throws out all the current work and loads the new page. How can I force Chrome to open the new URL in a new tab, or at least catch the exit from the current page so I can save the work for the user?
Thanks
You can create a javascript popup that runs when the user has modifyed the work with this line:
window.onbeforeunload = function(){ return 'All unsaved Work will be lost.' }
The popup will look something like this
Confirm Navigation
All unsaved Work will be lost.
Press OK to continue, or Cancel to stay on the current page.
Use this line to prevent the popup once the user saves:
window.onbeforeunload = null;
the following is on a page, when i click it - I DO NOT want the page to refresh, but only the new window which this link opens - i want to refresh that newly opened page, not the main window.
clicking the link opens the new window correctly, but refreshes the main window also (where the link lies). that is undesirable and i want to know how to stop it from doing so.
clik to open new window
clik to open new window
pl advice.
as advised below, but not working: infact it is breaking the new window, new window appears as blank window!
clik to open new window
Here's the proper way to open a link in a new window. If javascript isn't available, the link will still work.
Click Me
mywin is a window name, not a variable.
You need to store the returned wobject from window.open() in a global variable:
onclick="window.mywin = window.open('URL','mywin');">
The problem with the main window reloading is likely the href="" line. This could be causing the browser to navigate to the same page where it is presently (and therefore refreshing). You should add return false; to the js, and likely also adopt a more standard link target like href="#" which will navigate to the top of the same page without a refresh (though this will still get cancelled by the false return).
friends, it is resolved by doing this:
clik to open new window
I'm trying to focus an existing tab when the content reloads. The usual window methods don't seem to work.
Here's whats happening: On page_1 I have a link like...
Go to my other page
If the tab doesn't exist, when the link is clicked it opens a new tab and takes focus. (Perfect)
If you then go back to page_1 and click the link again, it reloads the content in the existing tab (perfect) but doesn't focus (crap). I've tried the usual window.focus, $(window).focus methods on load with page_2 without luck.
Any recommendations?
It is impossible.
The following appears to work in IE8 and FF13:
<script type="text/javascript">
// Stupid script to force focus to an existing tab when the link is clicked.
// And yes, we do need to open it twice.
function openHelp(a) {
var tab = window.open(a.href, a.target);
tab.close();
tab = window.open(a.href, a.target);
return false;
}
</script>
Help
There is a workaround to this. Use javascript to open a window in a new tab, store a reference to that tab, and when you want to focus it; close it first and then re-open it.
if (window.existingWindow != null)
try { window.existingWindow.close(); } catch (e) { };
window.existingWindow = window.open("/your/url", "yourTabName");
We use a similar approach to opening the preview pane of the current page you're working on in our service called Handcraft where the above works as expected (we wanted the new window to always focus).
Without using a framework you can put a script block at the bottom of your page that will run once the page loads. Because it is after your HTML you can be assured that the HTML is refers to is actually available.
The script can set the focus to the element you want.