1

我在下面有以下代码,它会生成按钮,当它们被点击时会向我发送一封电子邮件。

我现在想添加一个按钮以在按下按钮时打开网页,例如 www.bbc.co.uk。

我怎么做???

这是我运行的代码

https://script.google.com/macros/s/AKfycbw6yYRE7aroV3lXvXyfNYm15NeKa2FyBCvvvcOuD1k/dev

这就是它背后的代码。

    function doGet() {

      var app = UiApp.createApplication();


     var buttonPhilippaTitle = app.createButton('Philippa\'s Morning Routine')
        .setId('LabelPhilippaTitle');
        buttonPhilippaTitle.setHTML('<H1>Philippa</h1>');
        app.add(buttonPhilippaTitle);

     var buttonPhilippaUp = app.createButton('I have got up')
        .setId('LabelPhilippaUp');
        app.add(buttonPhilippaUp);
        var handler = app.createServerHandler('myClickHandlerPhilippaUp');
        buttonPhilippaUp.addClickHandler(handler);

      var buttonPhilippaApple = app.createButton('I have had an apple')
        .setId('LabelPhilippaApple');
        app.add(buttonPhilippaApple);
        var handler = app.createServerHandler('myClickHandlerPhilippaApple');
        buttonPhilippaApple.addClickHandler(handler);

      var buttonPhilippaBath = app.createButton('I have had a bath')
        .setId('LabelPhilippaBath');
        app.add(buttonPhilippaBath);
        var handler = app.createServerHandler('myClickHandlerPhilippaBath');
        buttonPhilippaBath.addClickHandler(handler);

      var buttonPhilippaPray75 = app.createButton('I have prayed for 75')
        .setId('LabelPhilippaPray75');
        app.add(buttonPhilippaPray75);
        var handler = app.createServerHandler('myClickHandlerPhilippaPray75');
        buttonPhilippaPray75.addClickHandler(handler);


      var buttonPhilippaEyesClosed50 = app.createButton('I have had my eyes closed for 50')
        .setId('LabelPhilippaEyesClosed50');
        app.add(buttonPhilippaEyesClosed50);
        var handler = app.createServerHandler('myClickHandlerPhilippaEyesClosed50');
        buttonPhilippaEyesClosed50.addClickHandler(handler);


      var buttonPhilippaCreamVitDeod = app.createButton('I have put on cream on my face, had a vitamin and put on deodorant')
        .setId('LabelPhilippaCreamVitDeod');
        app.add(buttonPhilippaCreamVitDeod);
        var handler = app.createServerHandler('myClickHandlerPhilippaCreamVitDeod');
        buttonPhilippaCreamVitDeod.addClickHandler(handler);   


    var buttonPhilippaCreamOnArms1 = app.createButton('I have put on cream on my arms once')
        .setId('LabelPhilippaCreamOnArms1');
        app.add(buttonPhilippaCreamOnArms1);
        var handler = app.createServerHandler('myClickHandlerPhilippaCreamOnArms1');
        buttonPhilippaCreamOnArms1.addClickHandler(handler);   


    var buttonPhilippaCreamOnArms2 = app.createButton('Cream Twice')
        .setId('LabelPhilippaCreamOnArms2');
        app.add(buttonPhilippaCreamOnArms2);
        var handler = app.createServerHandler('myClickHandlerPhilippaCreamOnArms2');
        buttonPhilippaCreamOnArms2.addClickHandler(handler);   



    var buttonPhilippaCreamOnArms3 = app.createButton('Cream Three Times')
        .setId('LabelPhilippaCreamOnArms3');
        app.add(buttonPhilippaCreamOnArms3);
        var handler = app.createServerHandler('myClickHandlerPhilippaCreamOnArms3');
        buttonPhilippaCreamOnArms3.addClickHandler(handler);   



    var buttonPhilippaCreamOnArms4 = app.createButton('Cream Four times')
        .setId('LabelPhilippaCreamOnArms4');
        app.add(buttonPhilippaCreamOnArms4);
        var handler = app.createServerHandler('myClickHandlerPhilippaCreamOnArms4');
        buttonPhilippaCreamOnArms4.addClickHandler(handler);   



    var buttonPhilippaCreamOnArms5 = app.createButton('Cream Five times')
        .setId('LabelPhilippaCreamOnArms5');
        app.add(buttonPhilippaCreamOnArms5);
        var handler = app.createServerHandler('myClickHandlerPhilippaCreamOnArms5');
        buttonPhilippaCreamOnArms5.addClickHandler(handler);   




    // Classical Radio Is On
    var buttonPhilippaClassicalRadioOn = app.createButton('I have put the classical radio on in my bedroom')
        .setId('LabelPhilippaClassicalRadioOn');
        app.add(buttonPhilippaClassicalRadioOn);
        var handler = app.createServerHandler('myClickHandlerPhilippaClassicalRadioOn');
        buttonPhilippaClassicalRadioOn.addClickHandler(handler);   


       var buttonPhilippaWashingUp = app.createButton('I have done some washing up')
        .setId('LabelPhilippaWashingUp');
        app.add(buttonPhilippaWashingUp);
        var handler = app.createServerHandler('myClickHandlerPhilippaWashingUp');
        buttonPhilippaWashingUp.addClickHandler(handler);


    // Shoe Crate Is Tidy
    var buttonPhilippaShoeCrateIsTidy = app.createButton('Shoe Crates Are Tidy Including All Girls Shoes In The Bedroom')
        .setId('LabelPhilippaShoeCrateIsTidy');
        app.add(buttonPhilippaShoeCrateIsTidy);
        var handler = app.createServerHandler('myClickHandlerPhilippaShoeCrateIsTidy');
        buttonPhilippaShoeCrateIsTidy.addClickHandler(handler);   



    // Cleaned Under My Bed
    var buttonPhilippaCleanedProperlyUnderMyBed = app.createButton('I Have Cleaned Properly Under My Bed')
        .setId('LabelPhilippaCleanedProperlyUnderMyBed');
        app.add(buttonPhilippaCleanedProperlyUnderMyBed);
        var handler = app.createServerHandler('myClickHandlerPhilippaCleanedProperlyUnderMyBed');
        buttonPhilippaCleanedProperlyUnderMyBed.addClickHandler(handler);   


     var buttonPhilippaSetGoalsForTheDay = app.createButton('I have set my goals for the day')
        .setId('LabelPhilippaSetGoalsForTheDay');
        app.add(buttonPhilippaSetGoalsForTheDay);
        var handler = app.createServerHandler('myClickHandlerPhilippaSetGoalsForTheDay');
        buttonPhilippaSetGoalsForTheDay.addClickHandler(handler);   

    var text1 = app.createTextArea();
      app.add(text1);
      text1.setText("*** Please email Daddy these goals once you have set them****\nPhilippa : My goals for the day are\n\nMorning\n\n\n\nEvening\n\n\nGoals For The Week\nSat\nSun\nMon\nTues\nWed\nThurs\nFri");
      text1.setWidth("100%");
      text1.setHeight("200");
      text1.setVisible(true);






      return app;

    }






    // Philippa Up
    function myClickHandlerPhilippaUp(e) {
      var app = UiApp.getActiveApplication();
      var label = app.getElementById('LabelPhilippaUp');
      label.setHTML('<h2 style="background-color:red;">Congratulations, Philippa!  You have got up ! ! !</h2>');
      var emailAddress = ('user@example.com');
      GmailApp.sendEmail(emailAddress, 'Philippa has got up','');            
      app.close();
      return app;
    }




    function myClickHandlerPhilippaApple(e) {
      var app = UiApp.getActiveApplication();
      var label = app.getElementById('LabelPhilippaApple');
      label.setHTML('<h2 style="background-color:red;">Congratulations Philippa you have started the day well with a piece of fruit.  Remember - God made fruit and salad, not chocolate!!!</h2>');
      var emailAddress = ('user@example.com');
      GmailApp.sendEmail(emailAddress, 'Philippa has had an apple!!!','');            
      app.close();
      return app;
    }




    function myClickHandlerPhilippaBath(e) {
      var app = UiApp.getActiveApplication();
      var label = app.getElementById('LabelPhilippaBath');
      label.setHTML('<h2 style="background-color:red;">Congratulations Philippa You Have Had A Bath!!!</h2>');
      var emailAddress = ('user@example.com');
      GmailApp.sendEmail(emailAddress,'Philippa has had a bath!!!','');            
      app.close();
      return app;
    }





    function myClickHandlerPhilippaPray75(e) {
      var app = UiApp.getActiveApplication();
      var label = app.getElementById('LabelPhilippaPray75');
      label.setHTML('<h2 style="background-color:red;">Congratulations Philippa you have had a proper prayer for 75!!!</h2>');
      var emailAddress = ('user@example.com');
      GmailApp.sendEmail(emailAddress,   'Philippa has prayed for 75!!!','');            
      app.close();
      return app;
    }




    function myClickHandlerPhilippaEyesClosed50(e) {
      var app = UiApp.getActiveApplication();
      var label = app.getElementById('LabelPhilippaEyesClosed50');
      label.setHTML('<h2 style="background-color:red;">Wow ! Did you really pray with your eyes closed for 50?  Did God speak to you Philippa?  Let me know!!!</h2>')
      var emailAddress = ('user@example.com');
      GmailApp.sendEmail(emailAddress,'Philippa has prayed for 50 with eyes closed!!!','');            
      app.close();
      return app;
    }




    function myClickHandlerPhilippaCreamVitDeod(e) {
      var app = UiApp.getActiveApplication();
      var label = app.getElementById('LabelPhilippaCreamVitDeod');
      label.setHTML('<h2 style="background-color:red;">Well done Philippa! Thanks for letting me know you have had cream, vitamin and deodorant!!!</h2>')
      var emailAddress = ('user@example.com');
      GmailApp.sendEmail(emailAddress,'Philippa has put cream on, had a vitamin and put deodorant on...','');            
      app.close();
      return app;
    }




    // Cream On Arms
    function myClickHandlerPhilippaCreamOnArms1(e) {
      var app = UiApp.getActiveApplication();
      var label = app.getElementById('LabelPhilippaCreamOnArms1');
      label.setHTML('<h2 style="background-color:red;">Well done Philippa! Thanks for keeping your arms moist!!!</h2>');
      var emailAddress = ('user@example.com');
      GmailApp.sendEmail(emailAddress,'Philippa has put cream on her arms once','');            
      app.close();
      return app;
    }


    // Cream On Arms
    function myClickHandlerPhilippaCreamOnArms2(e) {
      var app = UiApp.getActiveApplication();
      var label = app.getElementById('LabelPhilippaCreamOnArms2');
      label.setHTML('<h2 style="background-color:red;">Cream on arms twice</h2>');
      var emailAddress = ('user@example.com');
      GmailApp.sendEmail(emailAddress,'Philippa has put cream on her arms twice','');            
      app.close();
      return app;
    }


    // Cream On Arms
    function myClickHandlerPhilippaCreamOnArms3(e) {
      var app = UiApp.getActiveApplication();
      var label = app.getElementById('LabelPhilippaCreamOnArms3');
      label.setHTML('<h2 style="background-color:red;">Cream on arms three times</h2>');
      var emailAddress = ('user@example.com');
      GmailApp.sendEmail(emailAddress,'Philippa has put cream on her arms three times','');            
      app.close();
      return app;
    }


    // Cream On Arms
    function myClickHandlerPhilippaCreamOnArms4(e) {
      var app = UiApp.getActiveApplication();
      var label = app.getElementById('LabelPhilippaCreamOnArms4');
      label.setHTML('<h2 style="background-color:red;">Cream on arms four times</h2>');
      var emailAddress = ('user@example.com');
      GmailApp.sendEmail(emailAddress,'Philippa has put cream on her arms four times','');            
      app.close();
      return app;
    }


    // Cream On Arms
    function myClickHandlerPhilippaCreamOnArms5(e) {
      var app = UiApp.getActiveApplication();
      var label = app.getElementById('LabelPhilippaCreamOnArms5');
      label.setHTML('<h2 style="background-color:red;">Cream on arms five times</h2>');
      var emailAddress = ('user@example.com');
      GmailApp.sendEmail(emailAddress,'Philippa has put cream on her arms five times','');            
      app.close();
      return app;
    }




    // Classical Radio Is On
    function myClickHandlerPhilippaClassicalRadioOn(e) {
      var app = UiApp.getActiveApplication();
      var label = app.getElementById('LabelPhilippaClassicalRadioOn');
      label.setHTML('<h2 style="background-color:red;">I have put the classical radio on in the bedroom ! </h2>');
      var emailAddress = ('user@example.com');
      GmailApp.sendEmail(emailAddress,'Philippa has put the classical radio on in the bedroom','');            
      app.close();
      return app;
    }




    // Washing Up
    function myClickHandlerPhilippaWashingUp(e) {
      var app = UiApp.getActiveApplication();
      var label = app.getElementById('LabelPhilippaWashingUp');
      label.setHTML('<h2 style="background-color:red;">You are getting helpful, Philippa!!! Thanks for doing some washing up!!!</h2>');
      var emailAddress = ('user@example.com');
      GmailApp.sendEmail(emailAddress,'Philippa has done some washing up','');            
      app.close();
      return app;
    }




    // Shoe Crate Is Tidy
    function myClickHandlerPhilippaShoeCrateIsTidy(e) {
      var app = UiApp.getActiveApplication();
      var label = app.getElementById('LabelPhilippaShoeCrateIsTidy');
      label.setHTML('<h2 style="background-color:red;">Shoe Crates Are Tidy Including All Girls Shoes In The Bedroom</h2>');
      var emailAddress = ('user@example.com');
      GmailApp.sendEmail(emailAddress,'Philippa has tidied the shoe crates','');            
      app.close();
      return app;
    }






    // Cleaned Properly Under My Bed
    function myClickHandlerPhilippaCleanedProperlyUnderMyBed(e) {
      var app = UiApp.getActiveApplication();
      var label = app.getElementById('LabelPhilippaCleanedProperlyUnderMyBed');
      label.setHTML('<h2 style="background-color:red;">I Have Cleaned Properly Under My Bed</h2>');
      var emailAddress = ('user@example.com');
      GmailApp.sendEmail(emailAddress,'Philippa has cleaned under her bed','');            
      app.close();
      return app;
    }



    function myClickHandlerPhilippaSetGoalsForTheDay(e) {
      var app = UiApp.getActiveApplication();
      var label = app.getElementById('LabelPhilippaSetGoalsForTheDay');
      label.setHTML('<h2 style="background-color:red;">Thanks for setting your goals for today, Philippa ! ! !</h2>');
    var emailAddress = ('user@example.com');
    GmailApp.sendEmail(emailAddress,'Philippa Has Set Goals','');            
    app.close();
    return app;
    }
4

0 回答 0