Xrm.Utility.openwebresource opens new tab - javascript

We have an onprem crm 2016. I'm opening an html webresource on a click of a ribbon button. I'm using Xrm.Utility.openWebResource(...). The problem with that is we're using IE11 and all users' browsers are configured to let IE decide how to open pop ups.
Guess what, IE decides to open a new tab! Is there a way to open an html web resource in a new window without changing the users' browser options?

Xrm.Utility.openWebResource() performs different in Chrome compared to IE11. Below options are there, pick it what suits you.
window.open()
Unsupported way to open modal dialog - showModalDialog
Xrm.Internal.openDialog()
Source
Xrm.Utility.openEntityForm() has an option to mention as openInNewWindow = true in parameter windowOptions which is not available for openWebResource()

Related

Can't open new tab in JavaScript why? Do I need HTTPS?

When I try to open a new window using:
window.open('url?params','_blank')
it's treated as a popup.
Tried with this to:
<a hred='url?params' target='_blank'>Test</a>
same result.
Tested it on Chrome and Edge.
My site isn't marked as "Secure" in the browser. Does it have to be marked as Secure (HTTPS), to be able to open new windows?
The problem is not with your site being Secure or not.
The thing here is with browsers. They are designed to block new tab or new window as pop ups if they have not being effected/caused form a trusted event. That means the user has to actively click somewhere to open a popup or some submission has to happen to allow the pop up.
The answers from here and here should give you better insights.

New window opens when button is clicked but not when using .onclick()

I am using software that creates all the HTML/XML so I don't have this and I have created a button to open a form in a new window. When I physically click on this button, everything works. However when I run the code onload, I get a message saying that the page is blocked and I need to remove any popup blocker
var button = getElement("GUID_of_Button");
button.click();
This code works if I set to open the form in the same window as a tooltip but not as a new window. I tried on Chrome, Firefox and IE with same results. (no console error)
Not sure if this helps (get this when I inspect element)
<input name="buttoncontrol0F09F8F7" id="ID_buttoncontrol0F09F8F7" value="Click here" type="submit" title="Click here" class="Button_Standard" style="cursor: pointer;">==$0
Naturally I can remove any blockers but as this is for the whole office, I can't ask everyone to do this just so I can get this to work. Any advise is appreciated.
This is a feature of modern browsers that restricts the opening of new windows to user-initiated actions.
This is important as it mitigate security risks and gets rid of the most obnoxious advertising.
Unless you can get everyone to change their browser settings, you won't have a new window opened automatically.
Depending on the data you need to display, you could consider alternative to new windows such as modals / pop-ins. Take a look for example at Bootstrap's modal.
Popup windows are generally used for advertisement and these windows will be opened without permission of user. Inorder to prevent this, most of the web browsers comes with popup blockers which should be explicitly configured by user if they want to automatically open something in a new window.
If you want to use this featue, you'll have to ask users to configure popup blockers in their web browser.

Open URL in same window from different tabs

Let's say I have this function in a javascript on my web page that loads a url from an textfield with id url:
function loadUrl()
{
var url = document.getElementById('url').value;
window.open(url, 'urlwindow');
}
If I open two tabs in my browser and opens my web page in both tabs, I want both tabs to open the url in the same window, not two separate windows. Is this possible?
In other words, I want to target window opened from another tab.
You can't control the behaviur of the user's browser: just add as target windows "_blank" and hope your user have enough recent web client that opens a new tab and not a new window.
In my experience, this works perfectly (and just like you're trying to do it) with Firefox and IE, but not with Chrome or Safari.
Firefox and IE seem to use domain-specific namespaces for target names, while Chrome and Safari seem to use browser tab-specific namespaces for target names, so in these two browsers, 'urlwindow' as seen from tab A is different from 'urlwindow' as seen from tab B.
I'm trying to find a workaround for this myself, but have not yet been successful. See Chrome/Safari: how to open the same window from different tabs or windows

javascript : window.open

I am working in vb.net 2005. I am in a position to start a new browser with process.start().
Now I have to open that browser in a specific size(say height:300 width:500)
Process.Start("firefox.exe", "abc.html")
and I have written this following code on load of abc.html
var myRef = window.open('abc.html','','left=20,top=20,width=300,height=500');
but it does not resize.
If I add 1 button on this page and click on it (by writing same code on its click event), a new window with expected size opens.
Am I going wrong somewhere?
Thanx.
Firefox doesn't let pages resize the window by default. Also note, if you already have Firefox running then browser preferences will dictate whether you get a new window or a tab. You can force a separate instance of Firefox by using the -no-remote command line flag, but then you won't be able to use the default profile (only one Firefox instance per profile).
My questions for you are:
Why are you launching Firefox from another executable at all instead of just having users click on a link and have it open in their default browser?
If you do need to launch Firefox from an executable, why spend all this effort overriding the user's preferences and settings?
If you' re launching from an executable and are keen to annoy your users whatever the cost, why not just find and resize the Firefox window using the normal Windows APIs?

Stop Mozilla Firefox opening popups in a new tab

I am building a site which when you click a link it opens up two things; it opens up a pop-up and an external website in a new tab. This is so the user can interact with the pop-up whilst he/she browses the external webpage.
This was working fine for me but I think when my FF updated to version 15.0.1 on OSX lion, I can no longer get this to behave the way I want it to.
I have even changed the settings in FF: FF->Preferences->Tabs->Open new window in Tab instead to off and with no such luck.
I have also noticed that facebook connect on any site will open a new tab rather than a new pop-up too.
I can't seem to find any documentation on the web stating that this is FF's native behavior, even in their changelog.
Here is my javascript trigger which I am certain all the parameters are correct:
popWin = window.open('http://somesite.com','myTargetWindowName','height=650,width=450,pageXOffset=900,pageYOffset=900,scrollbars=yes');

Categories