Opening link in browser with FS_BUTTON
Author: dvasudevan
Publication Date: 12/14/2023 13:41
Hello all,
Any idea how I can open an external link in a browser with FS_BUTTON ?
Thanks
Tags: chrome, external link, fs_button, link
0
-
Author: cpe - 2/7/2024 15:52
Hey there,
have you tried calling a script with an FS_BUTTON and opening your URL from there?
Cheers
Connz0 -
Author: ChKo - 2/19/2024 15:58
Hi,
here is a solution that should serve as inspiration:
<FS_BUTTON name="pt_openUrl_button" hFill="yes" icon="media:question_mark" noBreak="no" onClick="script:sc_openurlinbrowser" style="firstspirit" useLanguages="no"> <LANGINFOS> <LANGINFO lang="*" label="Open link" description="Help"/> <LANGINFO lang="DE" label="Öffne Link" description="Hilfe"/> </LANGINFOS> <PARAMS> <PARAM name="p_url">https://www.your-target-domain.com/</PARAM> </PARAMS> </FS_BUTTON>
import de.adesso.firstspirit.template.AbstractExecutable; import de.espirit.firstspirit.access.BaseContext; import de.espirit.firstspirit.access.ClientScriptContext; import de.espirit.firstspirit.agency.OperationAgent; import de.espirit.firstspirit.webedit.server.ClientScriptOperation; import java.awt.*; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; public class OpenUrlInBrowserExecutable extends AbstractExecutable<ClientScriptContext> { private final String PARAM_URL = "p_url"; @Override public Object execute(){ String url = getStringFromParameters(PARAM_URL); //ContentCreator Case if(context.is(BaseContext.Env.WEBEDIT)){ openWindowWebEdit(url); } //SiteArchitect Case if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new URI(url)); } catch (URISyntaxException | IOException e) { context.logError("Could not open URL '" + url + "' !", e); } } return null; } private void openWindowWebEdit(String url){ ClientScriptOperation scriptOperation = context.requireSpecialist(OperationAgent.TYPE).getOperation(ClientScriptOperation.TYPE); String script = "window.open('"+url + "','_blank');"; scriptOperation.perform(script, false); } }0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
2 Kommentare