// confirm.jsx // Copyright 2007 // Written by Jeffrey Tranberry // Photoshop for Geeks Version 1.0 /* Description: This script demonstrates how use the confirm method */ // enable double clicking from the // Macintosh Finder or the Windows Explorer #target photoshop // Make Photoshop the frontmost application // in case we double clicked the file app.bringToFront(); /////////////////////////// // SET-UP // /////////////////////////// // create a variable called result to store the 'confirm' method var result = confirm("Yes or No?"); // use an if statement to get the results of the confirm dialog // If the user clicked 'Yes' then it's true if (result) { alert("You said, 'Yes.'"); } else { // // If the user clicked 'no' alert("You said, 'No.'"); } // Ask the user whether they want to perform an action or not. // Create a variable called 'answer' to store the 'confirm' method // The confirm method accepts the arguments (message, noAsDefaul, title) // message expects a string for the text to display // noAsDefault expects boolean true or false, whether you want the [No] button to be the default highlighted button // title expects a string for the title bar, which is ignored on Mac. var answer = confirm("Warning:\nDo you want to do this?", false, "Running an action"); // use an if statement to get the results of the confirm dialog // If the user clicked 'Yes' then it's true if (answer){ // Show a dialog instead of actually running an action. alert("Running action..."); // Or you could run an action if the IF statement is true. // doAction("My Great Action","Default Actions"); }