How to invoke the same browser instance from a web link - html

I have a link on my web page. When I click it I open a new window and show content in that window.
I would like to be able, in a second time, to click again in that link and, instead of opening a new browser window/tab, to get the previous instance and put content on it.
Is it possible in some way?
Thanks in advance, greetings.

In HTML you do this by specifying a named target:
Link 2
Link 3
Link 4
All will open in the same window.
Note: If the user has their preferences set to open new windows in tabs, these will all reference the same tab (vs. window)

Related

How to open new tab in browser (in same browser window) with TestCafe?

I am currently unable to open a new tab in the same browser window. Please refer scenario.
After login, the application opens the page in the same browser
window. I need to click on the card and after it will open in a new
tab and where I need to test everything. Currently, I need to
simulate a direct URL for a new tab but I want to open a new tab with
test case code.
Please let me know is it possible in the test cafe?
Thanks.
Yes, you can pass --disableNewWindow in testcafe/runner argument to open url in same tab.
Also, refer to https://testcafe.io/documentation/402841/guides/advanced-guides/multiple-browser-windows#disable-support-for-multiple-windows
--disable-multiple-windows

Why does a link open in the new tab but not in the current tab?

I have the following link on my page. The link points to an internal address.
Add XYZ and do ABC
When I click on the link, nothing happens. The browser shows a loading icon, but stays on the current page. If I right click on the link and say open in new tab, the link open perfectly in the new tab. What is the reason for this? How do I go about debugging this?
You need to set the target of the hyperlink element
Add XYZ and do ABC
Another example (which if copied directly into a HTML file will work)
Goto Google

Should a link specify how it is to be opened?

For example HTML's href tag has a target attribute that can force the page to be opened in a new window. But conceptually is this a good idea? Should the content determine how the user should read it? Or should this be entirely up to the user (right click -> open in new window)?
I disagree. A link shouldn't be forced to open in a new window. If the user wants to open it in a new window then it is up to them.
Normally when we redirect to a link which is of the current site then it should/may open in the same window. But if the link redirects us to another sire then its better to open it in a new window so that the user will stick to our(current) site. There is no specific rule. It is mainly done as per client's requirement.
One drawback of in opening the link using right--> click is it makes the user do one extra click. In case your page has 5 links and the user wants to open them in new windows/tabs each time he/she has to do an extra click. This is just an example. It all depends what the user wants.....

window.location.reload refreshing the main window

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

Open a link to new tab inside a ifame of iframe

I have a iframe-1 and it contains another iframe-1-1.[1]
Inside iframe-1-1 which contains a link.
When a user click the link:
It should open a new tab (For instance, Firebug/or Chrome).[2]
But it does not work. How can I do that?
[1] Why I have this question: because I code a webpage, it is embedded in Facebook, and I call FB.dialog it will show me a dialog is a iframe too.
[2] It works properly if I use wheel button to click.
You can't instruct a browser to open a new tab. The best you can do is to use target="_blank" and hope that the user is using a browser that will open a tab and not a new window.