Web Browser control : Opening the link in the same tab

KitaYama

Well-known member
Local time
Today, 09:20
Joined
Jan 6, 2022
Messages
1,885
I have a form with a web browser control.
The page that we access through this control, is designed to open the links in a new tab.
When I browse to this page in web browser control and click a link, the target page is opened in a new window out side of Access. (mostly with an error, sometimes successful)
Is there any way to force the link open in the same web browser control (and not a new window outside of Access)?

Some Sample link on the page: (254915390 is the order number.)
HTML:
<td align="LEFT" bgcolor="lavender" nowrap="">
    <a href="JavaScript:execSearch('1','254915390','502017','1','kc')" onclick="return screenEnabled(ScreenEnabled);">254915390</a>
    <input type="hidden" name="ACCCD1" value="19017">
    <input type="hidden" name="CUSTCD1" value="502017">
    <input type="hidden" name="ODRNO1" value="254915390">
    <input type="hidden" name="DISTNO1" value="1">
    <input type="hidden" name="CHKFLG1" value="">
</td>

The execSearch Function:
JavaScript:
function execSearch(nbr){
    document.ODRFM.nextURL.value = "TServletKc100";
    document.ODRFM.ACCCD.value   = document.ODRFM["ACCCD" + nbr].value;
    document.ODRFM.CUSTCD.value  = document.ODRFM["CUSTCD" + nbr].value;
    document.ODRFM.ODRNO.value   = document.ODRFM["ODRNO" + nbr].value;
    document.ODRFM.DISTNO.value  = document.ODRFM["DISTNO" + nbr].value;
    document.ODRFM.action = "/suppo/servlet/EdiGate_T";
    document.ODRFM.target = "_blank";
    document.ODRFM.submit();
}

We are on Microsoft 365, (not the latest version). So the Web Browser control is not the new version that was released a while back.
If updating to latest version can be a key point to solve the problem, certainly we will do.

Thanks for your time and help.

PS:
We also receive a csv file that contains Order Numbers. We have a query linked to this csv file and we know the links on the page.
It means that we have all the links (Order Numbers) on the page, listed in a combo box.
I was thinking to use the combo box to navigate the web browser control to the page by running the JavaScript in VBA.
 
Last edited:
Not sure if you can override the JS function using VBA; but if you can overwrite it, just remove the document.ODRFM.target = "_blank"; line from it.
 
Not sure if you can override the JS function using VBA; but if you can overwrite it, just remove the document.ODRFM.target = "_blank"; line from it.
Do you have the new web browser control? Is it a multi tab browser?

thanks.
 
How can I tell? What does it look like?

Sent from phone...
I have no idea. It may be something like Chrome, Edge or Firefox, with a tab bar at top or bottom of the control, to be able to select different tabs, or right click a link and select "Open in a new tab".

I really hate the new look of Office title bar in recent updates. That's why I've disabled the auto update option.

Thanks for trying to help.
 
If you have the BeforeNavigate event, you could potentially cancel the navigation and grab the target link and then use that as control source. It's just an idea. Another thing that could be done is check if the link being clicked has a "_blank" attribute to remove it.

I don't have that browser, so I can't really say if that's gonna work.
 
If you have the BeforeNavigate event, you could potentially cancel the navigation and grab the target link and then use that as control source. It's just an idea. Another thing that could be done is check if the link being clicked has a "_blank" attribute to remove it.

I don't have that browser, so I can't really say if that's gonna work.
Since the _blank is inside a javascript function, I can not change to _self.
In case of the first part of your suggestion, it's completely out of my league. (I suppose).

I think if you're out of ideas, then it's the end of the line. It seems no to be possible.
Thanks for your time though.
 
Since the _blank is inside a javascript function, I can not change to _self.
In case of the first part of your suggestion, it's completely out of my league. (I suppose).

I think if you're out of ideas, then it's the end of the line. It seems no to be possible.
Thanks for your time though.
I used the term "override" earlier, but the correct term I should have used was "overload." I asked ChatGPT, and it doesn't seem ti be too hard to do it. You can replace (overload) the existing function with something that will do what you want.

Sent from phone...
 

Users who are viewing this thread

Back
Top Bottom