Below link will be disappear after 1 click only in firefox, how to fix this?
Open page in new window
Fiddle Link
The link does not disappear, the problem is that firefox still links to the page in the attribute href in this case in the jsfiddle, it's linking to google.com, but google doesn't allow to embed google in an iframe, so you get a blank page in jsfiddle.
if you use javascript:void(0) inside your href the link will do absolutely nothing, if you use # it will link to a non existing anchor on your page, this is not a problem, but you see it in the address bar of your browser.
You can try this instead:
Open page in new window
If you just want to open the link in a new tab instead you can use target for this, some old browsers will still open this in a new window:
Open page in new tab
Try this:
Open page in new window
Related
Currently I am opening a new tab using window.open(url) and working fine.
But here, I required to make it as anchor tag because on mouse right click and open link in new tab is not showing for the window.open.
Can please suggest how I can convert window.open to anchor tag?
Also currently window.open capturing the parent window and performing the some activities.
Try this instead!
Link Text
Im stumped..... I'm using Fancybox jquery plug in to display some iframes over the top of my page in a lightbox style.... i have it all working but if I try to link to an external website from within the lightbox using the normal somesite
I before you suggest it I have tried target="_blank"with no luck.
it opens in the lightbox not in the original window, I dont mind if it opens in a new tab or windows I just cant have it opening in the lightbox... has anyone else experienced this before?
Just to make sure that I have understood the scenario here -
You have a link that when clicked, opens the content in a fancybox pop-up.
This content has some text and within that, it has a somesite link. You have also tried target="_blank".
When this <a>..</a> is clicked, it should act like a normal link and open in a browser (new tab or window). But it opens the this link in the fancybox pop-up instead.
If that's the case then I tried it and the link opened in a new tab.
Please clarify the above doubt of mine.
Thanks.
Try target="_parent" instead of target="_blank"
See following example:
somesite
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 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');
Example of what I want to do: On Facebook, clicking a link to open it in the current tab will trigger some JavaScript rather than opening the link. However, opening it in a new tab (either by right-clicking or by holding Ctrl/Cmd) will open the link without calling any JavaScript.
I'd like to do the same with my links (have link behaviour dependent on the target). I have the onclick event handler return false; to avoid opening the link; but this causes Ctrl+clicking to fail to open the link. How do I achieve this?
EDIT: I do not want links to forcefully open in new windows. IF a link is opened in a new window, I want it to follow the href as usual. However, IF the link is opened in the current window, rather than following the link in the current window, I want to have some JavaScript run.
Facebook does this to open an image in a popup "theatre" if you open it in the current window, and open it in a full page if you open it in a new window.
Note that capturing the click event on links and using preventDefault() or return false causes Cmd+Click (open in new tab) to fail. In any case, this should work regardless of how the link is opened - click, Enter key, etc.
EDIT 2: It seems that hashchange / HTML5 pushState is the correct way to go about this
You can set the href of the anchor pointing to correct url. This way right click and open in a new tab or window will work fine.
Use jQuery to bind the click event handler to the anchor like this.
$('a').click(function(e){
//Do whatever javascript operation you want.
if(!e.ctrlKey){
e.preventDefault();//Stop the page to navigate to the url set in href
}
});
Demo