function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Force TechieForce Techie 

Custom button with execute Javascript behavior on standard object functionality

Hi!

 

I am new to salesforce. I have " A custom button 'welcome' on standard Object(Account) detail page. This button have execute JavaScript behavior onclick. This button has JavaScript function name getMsg(). This getMsg only popup alert('hello'). The modal popup also have a button 'cancel'. When user clicks on 'welcome', popup is open. On popup user clicks 'cancel' , we want to execute the getMsg() method when cancel is clicked from modal popup."

Please help me to understand how to do this.

Thank You!

asish1989asish1989

HI

   Try this code 

              

{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}

   //window.alert('hi');
    // window.confirm("hi");
getMsg();
     function getMsg() {
        var isCancel = window.confirm('Hello');
        if(!isCancel){
             getMsg();
       }
      else return true;
   }

 Did this post answers your question if so please mark it as solved and hit kudos for this post

 

  Thanks

Force TechieForce Techie

Thanks!

 

But I am not talking about confirmation box. I am talking about popup window dialog box.

asish1989asish1989

Hi

Create a detail button on Account object and attach java script code to this button 

{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}

   
getMsg();
    function getMsg() {
       
 newwindow=window.open('https://c.ap1.visual.force.com/apex/PopupTestDetail','HI','height=180,width=150');
	if (window.focus) {newwindow.focus()}
	return false;
   }

 

I have designed a visualforce page like a popup , It contains two button "OK "  and "CANCEL" .I have not attched any java script function to cancel button, You will write a java script function as per your requirement that will be fired on onclick event of cancel button, You can not call getmsg() from cancel button, You can write same logic here also.

Here is my visual force page which act as popup window 

<apex:page showHeader="false" sidebar="false">
    <apex:form>
         <p>
         HELOO
        </p><br/><br/><br/>
     <apex:commandButton value="Ok"/>
     <apex:commandButton value="cancel"/>
    </apex:form>
 
</apex:page>

 Did this post answers your question, If so please mark it as solved and hit kudos icon for this post.

 

    Thanks