I am simply creating an HTML page, where I am using target="" in the link which opens up the page as target="_blank".
For Instance,
link
What I want is, when the user clicks on it, the blank page, which opens up, should open, but the main page from where the link is clicked should stay. Right now, it is acting like "target="_blank", which onclick shows the page redirected.
Is this possible ?
Not an exact answer to this problem but you can do a nasty trick to make it look so by opening the current page in new tab and loading the link in current tab. One disadvantage with this would be that current page will be in a tab next to new page.
You can do something like
<a href="https://google.com" onclick="window.open('#','_blank');window.open(this.href,'_self');">
I don't think you can control the browser behavior by manipulating which tab to focus, it is like letting me make changes to your bank profile information illegally. There is really nothing much you can do about it.
Related
My use case:
User already has web app open in a browser tab
An email is sent to the user with an anchor tag that takes user to a specific page in the web app
On clicking, the initial tab is repopulated with new page
To do this the anchor tag is formatted like <a target="webapp" href="example.com" >Click Here</a> and I have a tiny bit of javascript, triggered on load, in my web app like this window.name="webapp"
What is working:
If I test to make sure the window name was with window.name="webapp", doing console.log(window.name), it confirms that it was
If I click the link from the email and the web app isn't open yet a new tab opens. If I click that link again the tab that initially opened refreshes.
What isn't work:
If the user initially navigates directly to the web app (not via a link) and then clicks the link from the email, the link opens a new tab instead of repopulating the open tab. In this scenario I still get the correct window name in the console log but not the functionality I'm looking for.
Looking for insight into how to get this to work or if there's a better solution to this use case.
I have created a couple of pages whose content will be displayed in a pop up window.
I have a page where I define 3 links:
Page1<br />
Page2<br />
Page3
When clicking on the link, I have a popup displayed. But when clicking on another link, the popup is minimized. I need to keep it opened and display appropriate content from another page.
Unfortunately, I cannot use any javascript functions to focus my popup, since I need to put the links onto another vendor's website, that allows only simple html to be copied over, so when someone else will click the link, popup will open appropriate content.
Is there any way to achieve that with what I currently have?
I have a "quizzes" website where a list of quizzes is shown and each link opens a popup for a cute little quiz:
Start quiz »
On a desktop, I can have the user return to the quiz list with:
<a onClick="window.close()" href="#">Return to quizzes</a>
There's a couple of problems with this approach, and I'd like something better:
If the user arrived at this page with a target="_blank" link, then the "return" link should use window.close to get them back where they started
If the user agent ignores target="_blank" like iPad/Chrome then the "return" link should do a normal hyperlink to quizzes/index.htm
If the user came into quizzes/stable-tachycardia.htm via a direct link, the "return" link should do a normal hyperlink
Is there a good solution that covers each use case?
I'd have it link to a JavaScript function which checks for the presence of window.parent. If the parent window exists, open the desired URL in the parent and close the current window. If there is no parent, just open the URL in the current window.
Most resources suggest using onclick handler with trackEvent() for tracking outgoing links. BUT this way does not work with all navigation methods! It won’t work if you click with middle button (except Chrome) or control-click (except Chrome and FF) to open new tab, if you right-click and select new tab or window from context menu or if you drag link to another tab. Is such cases onclick is simply not called. You can check it with very simple link:
GO
Putting JavaScript in href attribute breaks the link in all cases when new tab or window is opened.
Putting onclick in span that looks like a link, will not allow users to decide if they want to open in new tab or not.
Finally, going through a redirect page, which tracks outgoing event, causes problems with back navigation – when users try to go back, they get back to the redirect page and then JS again redirects to the destination page. They need to click back twice … quickly.
Is there a better way, which would be both accurate and user friendly?
Context menu can't be detected by using JS. So if you want to catch that you need to use the redirect method. To fix the back button problem, redirect using location.replace to remove the tracking page from the back-button history.
I don't know any details about Google Analytics. In general, to track users' external navigation:
<a ping> is made for this purpose. If ping is not available, fall back to changing the links to go through a redirect page. Use a 302 redirect to prevent it from showing up in history; if you can't, try javascript:window.location.replace().
My requirement is that I have a few hyperlinks on a webpage and when the user clicks on these hyperlinks I should redirect the user to an asp.net web page(Default.aspx) in a different website.
For the 1st time when the user clicks on one of the hyperlinks it will launch a new browser window with the Default.aspx loaded and then if the user clicks on some other hyperlink I want to redirect the user to the existing browser window(in which deafult.aspx is already loaded)with the content related to this particular hyperlink loaded,instead of launching a new browser window/tab.
But I am not sure of how to achieve this.I wonder if I can add some js to the asp.net Default.aspx page to achieve this.
Please could someone put me in the right direction?
Thanks
It sounds like the target property of the <a> tag will serve your purposes. Try:
Link 1
Link 2
Any clicks on the link subsequent to the first one should not result in additional windows.