简体   繁体   English

Visualforce 页面中的命令按钮

[英]Command Button in Visualforce Page

I am using the following lines of code in my VF page to open the URL & it's opening in the same tab but I need to open a new Tab as soon as clicking the custom URL Button?我在 VF 页面中使用以下代码行打开 URL 并且它在同一个选项卡中打开,但我需要在单击自定义 URL 按钮后立即打开一个新选项卡?

<apex:commandButton action="{!URLFOR($Action.My_Obj__c.My_custom_link)}" value="My custom button"/> <apex:commandButton action="{!URLFOR($Action.My_Obj__c.My_custom_link)}" value="我的自定义按钮"/>

I don't think I have ever seen a button that opens something as new tab/window?我想我从来没有见过一个按钮可以打开新标签/窗口? Link yes, but not button.链接是的,但不是按钮。 Think if that's really what you want, user might be surprised with unexpected behaviour.想想如果这真的是你想要的,用户可能会对意外的行为感到惊讶。

Try using <apex:commandLink action="{!URLFOR($Action.My_Obj__c.My_custom_link)} target="_blank"> . You could style it to look like button by looking at class names (both in Classic and Lightning Experience).尝试使用<apex:commandLink action="{!URLFOR($Action.My_Obj__c.My_custom_link)} target="_blank"> 。您可以通过查看类名(在 Classic 和 Lightning Experience 中)将其 样式设置为看起来像按钮

If that doesn't work - worst case you can always capture onclick and do window.open or whatever from there...如果那不起作用 - 最坏的情况是你总是可以捕获onclick并从那里执行window.open或其他任何...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM