How to open links in Safari from React Native's WebView component - uiwebview

In the app, I'm using React Native's WebView component. If the user clicks on any links explicitly I would like it to open in Safari, instead of the WebView component being directed to that URL.
<WebView
source={{uri: 'https://some-url-here'}}
style={{marginTop: 20}}
/>

For IOS, you can use onShouldStartLoadWithRequest prop. The prop is called when webview is opening a new page. You can return false to stop loading and use React native Linking api to open url in safari.
Your onShouldStartLoadWithRequest could look like following:
onShouldStartLoadWithRequest={(navState)=>{
Linking.openURL(navState.url)
return false;
}}

Related

Embed Web Page with Fluent UI Northstar

I am trying to use the Embed component in Fluent UI Northstar to embed a SharePoint Web Page:
<Embed
iframe={{
allowFullScreen: true,
src: "https://tenant.sharepoint.com/sites/SiteName/Lists/ListName",
frameBorder: 0,
height: '400px',
width: '711.11px',
}}
/>
The page doesn't get loaded, all I see in the page is a play icon:
What am I missing?
The component is used within the same SharePoint site, so the user is already authenticated.
I got it to work. I had to give the Embed component a width and height, and use the active prop to have the iframe load automatically without pressing "play".

Embed Acumatica New Screen page in Website

I am trying to build a Support page for my website which should have Acumatica New Case Screen for customers to create a new Case. I tried using iFrame but when logged in, Selectors and dropdown don't respond. Any Suggestions how do I get New Case screen for my Support page just like in Acumatica Partner's portal.
This is working for me:
1) Create an acumatica portal web site; Make sure sp203000 page is accessible and works fine.
2) Create a simple html page and assign iframe src to be sp203000 screen url:
<!DOCTYPE html>
<html>
<body>
<style>
iframe {height:800px; width:1200px;}
</style>
<iframe src="http://localhost/AcuPortal/pages/sp/sp203000.aspx?CaseCD=null&CaseClassID=BILLING">
<p>Your browser does not support iframes.</p>
</iframe>
</body>
</html>
And it works fine:
New Case form embedded into frame
First time you will see the login screen in the frame. If you want users to see the form without logging in you need to think about some SSO solution for your site and acumatica.

Assign command keyboard shortcut from popup or options

Is it possible with the Chrome API to let users assign a keyboard shortcut from within the extension popup or options page? Without them having to go to extensions page, scroll to the bottom and open keyboard shortcut menu.
In Chrome there's no method to assign a shortcut key programmatically, but you can add a button or a link in the extension popup that will open the built-in dialog.
popup.html:
<button id="hotkey">Assign a shortcut key</button>
<script src="popup.js"></script>
popup.js:
document.getElementById('hotkey').onclick = () => chrome.tabs.create({
url: 'chrome://extensions/configureCommands'
});
Notes:
chrome:// URLs can be opened only via chrome/WebExtensions API methods,
but not via <a href="..."> links directly.
You can still use a standard <a> link with a click listener shown above; just don't forget to prevent the default click event to avoid an error in the console:
document.getElementById('hotkey').onclick = event => {
chrome.tabs.create({url: 'chrome://extensions/configureCommands'});
event.preventDefault();
};
In Opera browser the URL is opera://settings/configureCommands
You can detect the browser using navigator.userAgent string
In Firefox there's currently no way to open this UI programmatically so you'll have to show an instruction to open about:addons page, click the gear icon, then choose "Manage extension shortcuts". However, Firefox allows setting the hotkeys programmatically using browser.commands.update.

From popup.html, how can I run a javascript function by button onclick?

I'm trying to build an extension for Chrome, but I'm a newbie and I'm having trouble understanding the Docs provided by Google. I want the extension to have a popup that shows a few buttons, and when a button is clicked, I want to run a script.
This is my setup:
popup.html
<button id="test1" onclick="getSite();">button 1</button>
<button id="test2" onclick="getSite();">button 2</button>
content_script.js
function getSite(){alert('getSite works!');}
I'm having trouble understanding how to use the chrome javascript api, as I see others saying use chrome.tabs.executeScript, but I can't figure out where that line goes. Can anyone help me? I'll give you a cookie! or just an upvote.. or maybe both?
You haven't mentioned on which page you want your scripts to run onclick, in Popup.html page or the page on which user is currently working on the browser. If it is just the popup.html page in which you want to execute your script, include them in popup.html page itself.
If however you want to execute them on the user's browser page, You will have to pass a message to your background page, which in turn will execute chrome.tabs.executeScript with current tab's id and {file: 'yourjsfile.js'} as arguments.
I think you are having this problem because of restrictions imposed by the Google Content Security Policy. It mentions that iniline javascript like the one that you have mentioned in you code will not be executed. Try removing the onclick="getSite()" from your HTML markup to content_script.js. Use addEventListener function to attach the event to the button.

Chrome extension

I just made a Chrome extension. I followed this tutorial to get a nice button in my toolbar. Now if I load a page, the javascript in my extension gets executed.
Unfortunately, if I click the extension's button in my toolbar, nothing happens.
Question: How do I make the js get executed when I click the extension's button in my toolbar?
Thanks for your help.
Edit
I added background.html and it still doesn't work:
<html>
<head>
<script>
// Called when the user clicks on the browser action.
chrome.browserAction.onClicked.addListener(function(tab) {
var action_url = "javascript:mathjax.js";
chrome.tabs.update(tab.id, {url: action_url});
});
</script>
</head>
</html>
You have two options. Either, you can specify a "popup": "popup.html" in your manifest.json, then put the code in popup.html. In this case, the code will get executed in the popup (though of course you can communicate with your background page or anything else).
Probably better would be to put a callback in background.html by attaching a listener to chrome.browserAction.onClicked.
Chrome extension doesn't support inline javascript code in background.html.You must specify external javascript file.Also instead of specifying background.html you can directly specify external file in manifest file in background property.
I have answered similar question here.

Resources