This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Programmatically open new pages on Tabs
I have a link in my page and i want it to be opened in a new tab when the user clicks it?
That depends on the users browser settings. You can't control that as far as I know. All you can do is get it to open in a new windows, but if the user has his/her browser setup to open new windows in a new tab, it will do that.
So basically, the best you can do is open in a new window.
target="_blank"
i.e.
link text here
Most browsers treat a _blank target as opening in a new tab.
Set the target to _blank:
Use the target attribute set to _blank:
example
The exact behavior depends on the browser and user settings, so this is the best one can do.
This is considered bad practive because you (the web developer) is trying to control what the users browser is doing. It should be up to me how I want to open the link. Other than that lecture (and I understand that this may not be your decision), it doesn't seem that there is a way to do this.
Related
I know this question has been already asked and answered but I am not able to get exact solution what I require. Actually I want to either disable this option or I don't want to allow browser to open a new window neither blank nor with content. Also I don't want to remove HREF from the tags in my html.Any kind of guidance will be highly appreciated.
I am using Mozilla Firefox and I am trying to figure out a way to access the content of other tabs in the same window using JavaScript and the DOM (I am open to other techniques if exist).
E.g., I want to run JavaScript code in tab1 which can find the title of some other tab. Basically I need this so that I can identify a tab which has opened due an href in my current page without using window.open method. All I want is a simple hyperlink which opens a page belonging to the same domain as the current page (the page should be opened in a new tab). Now I want to be able to access this new tab from the current tab.
Whilst you can easily open a new window using JavaScript, I'm sure that is as far as it goes. From a security point of view you wouldn't want JavaScript in one tab being able to query / access the DOM in another tab. Any site would then be able to gain access to your bank account details, etc. if both sites were opened in separate tabs.
You can access the new window/tab if it was opened with JavaScript and the page indeed is in the same domain.
You can open the window/tab like so
var win = window.open("/path_to_page");
Then you'll have to wait for the page to load before you can access e.g. the title.
win.onload = function(){ alert(win.document.title); };
You could use HTML5 cross-window messaging (archive.org link...but that's kind of cutting edge.
Even in that case, you'd probably need to hijack the <a> tag 'click' event with JavaScript and open the window yourself so that you'd have access to the new window object for posting messages.
Try setting a cookie which is accessible to any page in the same domain. On other pages, use a JavaScript timer to check if the cookie value has changed and when it has you can use its value and take an action.
It worked for me.
Well, this would not be possible, you could try
<a target="_blank" rel="opener" href="about:blank"></a>
This makes a link that opens an about:blank, this will have the same domain as the page that opened It because of the Same-Origen-policy.
I am having a Proposal Builder Custom Formula(TEXT) using hyperlink on opportunity. When i click that i am trying to open a VF page in new window.
Hi, i need help on this salesforce task plzz.
My requirement is..
I opened Opportunity In IE and when i click Proposal Builder link on Opp, then that VF page should open in CHROME.
Any Suggestions or ideas plzzz..
Here is the Formula field i created:
HYPERLINK("https://mysalesforceorg.com/apex/cpq?opportunity_id="& Id &""e_id="& Id &"&Session_id="&$Api.Session_ID,"Proposal Builder","_blank")
CPQ is the VF Page to be opened when clicked.
Thankyou...
There is no way to force a browser to pass a URL to a different browser. It would be possible to create shortcuts on your desktop to open certain bookmarks in a specific browser, but what you are asking for is not possible. Once you're operating in a browser, it's going to handle any links/redirects/actions within itself (whether that be in the current tab, in a new tab, or in a new window).
With that said, there are certain extensions for Chrome that would allow an end user to render a page using an IE tab within Chrome...but there's no way for you as the developer to guarantee your users are going to do that.
I have an application where I have tabs where each tab represent a particular sub application.
I'd like to have all links such as site.com/* to open in an already existing browser tab, and somehow possibly firing a JavaScript event that a new link was received/opened so that I could open it in my application instead.
So basically, I'm building a web application and I'd like to have links opening in the same application instance rather than creating multiple instances of my application.
Is this possible?
Update: I'm talking about if someone sends a link over Skype or email, that the links would open in my application. I'm aware of most web technologies and I can't think of any approach, that's why I left this question if someone might have an idea. Or a plugin, if not, someday we might get one and I'll add the answer my own / update question.
Yes. Just use the target attribute of the links to open them in their sub-application browsing context (i.e. tab, window).
There is no event that fires on opening links. You may add a click event handler to all links, executing what you need when the URL matches.
If you want you want your web application to open specific protocols or mime types, even that is possible with HTML5. You can use window.navigator.registerProtocolHandler() and window.navigator.registerContentHandler(). See the HTML5 Draft on Custom scheme and content handlers.
If a users opens a new tab/window for a link he received by email etc, you usually can't catch and prevent that. But you could use Cross-document messaging, e.g. window.postMessage, to look whether your app is already opened somewhere in the browser and then close one tab and focus the other.
In my html code there are several link like this:
example
Is there a way to open these links in a new tab ( and not in a new window ) ?
You cannot control the preference the user has set in their browser. You might consider adding some text like
"Hold down the Ctrl key and click the following link"
If the user follows your suggestion, the page will open in a new tab. None of this is optimal.
See HTML: how to force open links in a new tab for more.
target="_blank" attribute should open that page in a new tab. It probably depends on your browser settings whether the page opens in a new tab or window.
There is no way to do this, short of a browser plugin.
That is for a reason. You do not want to take the user somewhere they don't want to be.
They may not want to be in Internet Explorer.
What you SHOULD do is suggest that your website may only be compatible with IE. This way, the user can only blame themselves if something does not work. Not ideal, but it's generally accepted practice.