is there any way to use javascript to open a link in an external program and not(!) in the web browser?
Background: From CRM2015 on-premise i want to open a Mail in Lotus Notes.
script:
<html>
<body>
<p onclick="myFunction()">Click me</p>
<script>
function myFunction() {
window.open("notes:///server/file");
}
</script>
</body>
</html>
What happens: the mail opens in Lotus Notes -> good
But also an additional tab in IE11 occurs, blank page and link in address bar -> bad
What should happen: mail will open in Lotus Notes but no additional tab or windows in IE11.
Is there any way to solve my issue?
Thanks a lot for you help and have a great weekend!
If you want to navigate to an external protocol via JS, do it the same way you'd navigate to a HTTP URL:
function goSomewhere() {
window.location = "notes:///server/file";
}
Sane browsers should 1. stay on the same page, and 2. launch the external program (emphasis on should and no guarantees on insane browsers - e.g. IE8 and below).
Related
I have an HTML page that contains a button says "Open Popup". Once this button is clicked, a popup window opens (using window.open).
The new popup window is an HTML page that contains a simple input filed and a submit button. Once the submit button is clicked, the popup window should close, and the text that's just been typed in the input field should now be displayed in the parent window.
I've tried doing it using opener.document.getElementById. It works perfectly in Firefox, but not in Chrome.
This is the code of my parent page (parent.html):
<!DOCTYPE html>
<html>
<body>
<button type="button" onclick="openPopup()">Open Popup</button>
<p id="result"></p>
<script type="text/javascript">
function openPopup() {
var popupWindow = window.open('popup.html', '', 'width=300, height=200');
}
</script>
</body>
</html>
And this is the code of my popup (popup.html):
<!DOCTYPE html>
<html>
<body>
<input type="text" id="userText" placeholder="Please enter some text">
<button type="button" onclick="submitText()">Submit!</button>
<script type="text/javascript">
function submitText() {
opener.document.getElementById('result').innerHTML = 'The text you\'ve entered is: ' + document.getElementById('userText').value;
self.close();
}
</script>
</body>
</html>
Note: Both parent and popup files are located in my desktop.
As mention, it works in Firefox, but not in Chrome. When I click the "Submit!" button in Chrome, nothing happens, and the following error shows up in the console:
Uncaught DOMException: Blocked a frame with origin "null" from accessing a cross-origin frame.
I spent hours trying to find help online, but I still can't make Chrome pass data from popup window to parent page (which both are, as mentioned, located in my desktop, i.e. in the same directory).
Thanks in advance.
What you are encountering is a security feature of Chrome that is applying a web security standard called CORS (Cross-Origin Request Specification). It's meant to prevent one website from accessing another (because this is a common technique to try and trick people into giving up personal information), unless both the pages originate from the same domain. For example, http://domainA.com shouldn't be able to communicate with http://domainB.com by default. In situations were this is a legitimate need, server configuration is required to allow it.
Because you are running your tests from your desktop (without a web server) no domain information is present and Chrome thinks you are making a Cross-Origin Request.
If you run your files from a web server (over http or https), it will work.
There are many free web servers available for you to set up on your local machine and many development tools incorporate their own web servers. For example, VS code and Visual Studio are both free and have web servers included.
I am using this as my link in webpage.
<a class="btn btn-lg btn-orange" role="button" onclick="myFunction()">like me</a>
And this as my script.
function myFunction() {
$(function(){
window.location = "fb://profile/1456471431314551";
setTimeout(function () { window.location = "https://www.facebook.com/angelsatwork2015"; }, 25);
})
}
When I open in mobile both the browser fb page and the fb app open. Please help so that if the app opens it does not redirect to fb browser page.
Also when I use this code on desktop two different browser pages open.
This is most likely the expected behavior for that code.
What you're doing when that button is clicked is immediately opening the URL fb://profile/1456471431314551. Assuming this is iOS, this causes the system to show an alert asking if you want the app to launch. However, as of iOS 9.2, this alert is non-blocking, which means other code continues to execute in the background. This is why, 25 milliseconds later, you're opening the URL https://www.facebook.com/angelsatwork2015 as a regular webpage.
Unfortunately there is no good solution to this in the iOS 9.2+ world (thanks, Apple...). What we do at Branch.io is a combination of Universal Links (which launch the app when it is installed...most of the time) and redirections like the one you're trying for edge cases where Universal Links don't work. We set tracking cookies based on device UUID to know when we are safe to attempt launching the app, but in reality, this often means we have to redirect to the App Store if we aren't sure, just to avoid the behavior you're encountering.
I need two pages to be open at once when the user clicks on an image that is being sent in an email message.
I tried to use window.open but when the message is sent to the recipient the link on the image does not work.
Could you help me or tell me a better way to make this possible??
The code:
<img width="500" align="center" src="img_1">
Within email app, it's not possible. As Quentin mentioned above, all of the email consumption software, including Outlook, webmail and iPhone native email app will block your JavaScript in the message.
However, in theory, the result could be achieved using an intermediary landing page, which would perform the all the JS you need, opening two tabs.
I once had a similar project where we implemented intermediary landing page that sniffed the user agent and redirected to the deep-linked mobile website or a different desktop landing page. For example, you would link to your landing page like:
http://yourlandingpage.com?tab1toopen=http://page1.com&tab2toopen=http://page2.com
This raises new issues around:
* URL tracking (and automating encoding and/or optional URL shortening and admin of all of this),
* URL length (which is limited on Windows desktop Outlook clients),
* security of that landing page (lander should sanitize the strings, maybe even do some secret hand-shaking via unique encrypted var), and,
* can it sustain the heavy traffic (which is larger problem that it appears if you work with big brands).
Due to major security issues, scripting is not available in emails. Many clients will strip the scripting completely while others can mark it as spam or block it entirely.
Your best bet would be to have it link to a static landing page that then runs a script to open the two windows for you.
http://javascript.about.com/od/reference/a/jsemail.htm
Some other good sources on what is allowed and not allowed in HTML email:
http://kb.mailchimp.com/campaigns/design/limitations-of-html-email
http://kb.mailchimp.com/templates/code/common-html-mistakes
https://www.campaignmonitor.com/dev-resources/guides/coding/
How about this?
HTML
<img width="500" align="center" src="img_1">
JS
<script type="text/javascript">
function DoThis() {
window.open('http://www.foo.com', _blank); //open link 1 in new tab
window.open('http://www.g1.com.br', _blank); //open link 2 in new tab
}
</script>
In our web application we need to find out if a Custom URL Protocol Handler is registered or not in windows 10 machine using javascript with Windows 10 EDGE Browser.
If the Custom URL Protocol Handler is not registered in the windows 10 machine we will ask the user to download our desktop standalone app.
If registered we will start our desktop standalone app using the registered Custom URL Protocol Handler.
Since EDGE is a new browser the solutions provided by other users in the internet are not working.
Links I referred that are not working for me in EDGE browser:
https://gist.github.com/keyvanfatehi/f2f521c654bab106fdf9
Please help me out,
Thank you
Maybe this workaround helps:
Whenever you navigate to an unkown protocol with MS Edge, Windows asks the user about the app to handle this protocol. You could just navigate to your protocol and display a message with some information about what to do if the tool does not open. Something like this (sorry for the German screenshot):
<div id="toolBox">
<p id="toolBoxText"></p>
<input type="button" id="toolButton" onclick="openTool()" value="Start tool" />
</div>
<script type="text/javascript">
function openTool(){
window.location = 'myprotocol://command/';
document.getElementById("toolButton").value = "Try again";
document.getElementById("toolBoxText").innerHTML = "Thank you for using our tool. If the tool did not open successfully, please first download and install the tool <a href='download/'>here</a> and then try again."
}
</script>
I save this file as test.html and when I opened this file in IE, I am getting Information Bar for ActiveX Controls, Is there any way we can disable this thing using javascript code or jQuery code?
<html>
<body>
<h1>My First Web Page</h1>
<script type="text/javascript">
if(navigator.appName == "Microsoft Internet Explorer")
{
window.location = "http://www.google.com/"
}
else
{
window.location = "http://www.yahoo.com/"
}
</script>
</body>
</html>
And I just wanted to make sure, as I am running locally on my box so that is the reason it is showing ActiveX control Information bar? And Once I upload this file to a remote server and access it from there then this active x bar will not appear??
But is there any way programmatically to disable this information bar? Any suggestions will be appreciated.
Use Mark of the Web (MOTW). We can disable the ActiveX controls warning by putting following code before the opening html tag:
<!-- saved from url=(0014)about:internet -->
<html>
<body>
......
</body>
</html>
The above code is call “Mark of the Web (MOTW)”, this is a feature of Windows Internet Explorer that enhances security by enabling Internet Explorer to force Web pages to run in the security zone of the location the page was saved from
The Information Bar you're seeing is unrelated to ActiveX (even though it might say "ActiveX"). It's simply telling you that a IE isn't running scripts on a local file, a security precaution.
Yes, when accessed via HTTP, the warning won't appear.
There's no way to programmatic disable it because (1) your code isn't running in the first place; and (2) doing so would circumvent the security restriction that this is meant to be. Use the MOTW.
If you just want pages to work on your machine, go to Tools, Internet Options, Advanced, and check Allow active content to run in files on My Computer. I'd only enable this option while developing, however.