第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

需要在我使用 javascript 添加到我的頁(yè)面的按鈕的 onclick 事件上傳遞參數(shù)

需要在我使用 javascript 添加到我的頁(yè)面的按鈕的 onclick 事件上傳遞參數(shù)

回首憶惘然 2021-11-12 16:01:45
我有一個(gè) javascript 包含在我的一些頁(yè)面上,它將在頁(yè)面上列出的任何聯(lián)系人上創(chuàng)建一個(gè)按鈕。該按鈕的目的是使用戶(hù)可以輕松地向該聯(lián)系人發(fā)送電子郵件,并且該電子郵件將包含諸如站點(diǎn) URL 之類(lèi)的信息。我使用以下包含我的函數(shù)調(diào)用<script type="text/javascript" data-Subject="Site" src="../SiteAssets/js-test/AddContactButtons.js"></script>我的 AddContactButtons.js 有以下來(lái)源:$(document).ready(function() {      // Get the subject type    var this_js_script = $('script[src*=AddContactButtons]');    var subjectType = this_js_script.attr('data-Subject');     if (typeof subjectType == 'undefined' || subjectType == null || subjectType == ''){      subjectType = "Site";    }    //console.log('subjectType='+subjectType);    addContactButtons(subjectType);});function addContactButtons(subjectType){    var listTitle="Contacts";    console.log('addcontactButtons:subjectType='+subjectType);    $("table.ms-listviewtable[summary='"+listTitle+"']>tbody>tr").each(function(){        $(this).append("<input type='button' value='Help' style='background-color:#0072C5; color:white' class='btnSub' onclick='javascript:openMail(this);'>");    });}function openMail(btn){    var emailString = "mailto:";    var emailID = $(btn).prev("td").text()    //console.log(emailID);    console.log('openMail:subjectType='+subjectType);    emailString += emailID ;    emailString += "?Subject=SharePoint Site Support - Site=";    emailString += _spPageContextInfo.webServerRelativeUrl;;    //alert(emailString);    location.href=emailString;}問(wèn)題是我嘗試了很多不同的變體,但似乎無(wú)法將變量 subjectType 用于我的 openMail 函數(shù)。理想情況下,我想支持默認(rèn)的站點(diǎn)支持主題,但我需要選擇發(fā)送自定義主題或至少一些其他變體來(lái)告訴收到電子郵件的人它是用于支持自定義列表(應(yīng)用程序) .
查看完整描述

3 回答

?
holdtom

TA貢獻(xiàn)1805條經(jīng)驗(yàn) 獲得超10個(gè)贊

我有一個(gè) javascript 包含在我的一些頁(yè)面上,它將在頁(yè)面上列出的任何聯(lián)系人上創(chuàng)建一個(gè)按鈕。該按鈕的目的是使用戶(hù)可以輕松地向該聯(lián)系人發(fā)送電子郵件,并且該電子郵件將包含諸如站點(diǎn) URL 之類(lèi)的信息。


我使用以下包含我的函數(shù)調(diào)用


<script type="text/javascript" data-Subject="Site" src="../SiteAssets/js-test/AddContactButtons.js"></script>

我的 AddContactButtons.js 有以下來(lái)源:


$(document).ready(function() {  


    // Get the subject type

    var this_js_script = $('script[src*=AddContactButtons]');

    var subjectType = this_js_script.attr('data-Subject'); 

    if (typeof subjectType == 'undefined' || subjectType == null || subjectType == ''){

      subjectType = "Site";

    }

    //console.log('subjectType='+subjectType);

    addContactButtons(subjectType);

});

function addContactButtons(subjectType){

    var listTitle="Contacts";

    console.log('addcontactButtons:subjectType='+subjectType);

    $("table.ms-listviewtable[summary='"+listTitle+"']>tbody>tr").each(function(){

        $(this).append("<input type='button' value='Help' style='background-color:#0072C5; color:white' class='btnSub' onclick='javascript:openMail(this);'>");

    });

}

function openMail(btn){

    var emailString = "mailto:";

    var emailID = $(btn).prev("td").text()

    //console.log(emailID);

    console.log('openMail:subjectType='+subjectType);


    emailString += emailID ;

    emailString += "?Subject=SharePoint Site Support - Site=";

    emailString += _spPageContextInfo.webServerRelativeUrl;;

    //alert(emailString);

    location.href=emailString;

}

問(wèn)題是我嘗試了很多不同的變體,但似乎無(wú)法將變量 subjectType 用于我的 openMail 函數(shù)。理想情況下,我想支持默認(rèn)的站點(diǎn)支持主題,但我需要選擇發(fā)送自定義主題或至少一些其他變體來(lái)告訴收到電子郵件的人它是用于支持自定義列表(應(yīng)用程序) .


查看完整回答
反對(duì) 回復(fù) 2021-11-12
?
婷婷同學(xué)_

TA貢獻(xiàn)1844條經(jīng)驗(yàn) 獲得超8個(gè)贊

選項(xiàng) 1:創(chuàng)建一個(gè)全局變量“subjectType”來(lái)實(shí)現(xiàn)它。修改代碼如下。


var subjectType="";

$(document).ready(function() {  


    // Get the subject type

    var this_js_script = $('script[src*=AddContactButtons]');

    subjectType = this_js_script.attr('data-Subject'); 

    if (typeof subjectType == 'undefined' || subjectType == null || subjectType == ''){

      subjectType = "Site";

    }

    //console.log('subjectType='+subjectType);

    addContactButtons(subjectType);

});

function addContactButtons(subjectType){

    var listTitle="Contacts";

    console.log('addcontactButtons:subjectType='+subjectType);

    $("table.ms-listviewtable[summary='"+listTitle+"']>tbody>tr").each(function(){

        $(this).append("<input type='button' value='Help' style='background-color:#0072C5; color:white' class='btnSub' onclick='javascript:openMail(this);'>");

    });

}

function openMail(btn){

    var emailString = "mailto:";

    var emailID = $(btn).prev("td").text()

    //console.log(emailID);

    console.log('openMail:subjectType='+subjectType);


    emailString += emailID ;

    emailString += "?Subject=SharePoint Site Support - Site=";

    emailString += _spPageContextInfo.webServerRelativeUrl;;

    //alert(emailString);

    location.href=emailString;

}

方案二:使用jQuery代碼實(shí)現(xiàn)點(diǎn)擊事件。


$(document).ready(function() {  


    // Get the subject type

    var this_js_script = $('script[src*=AddContactButtons]');

    var subjectType = this_js_script.attr('data-Subject'); 

    if (typeof subjectType == 'undefined' || subjectType == null || subjectType == ''){

      subjectType = "Site";

    }

    //console.log('subjectType='+subjectType);

    addContactButtons(subjectType);

});

function addContactButtons(subjectType){

    var listTitle="Contacts";

    console.log('addcontactButtons:subjectType='+subjectType);

    $("table.ms-listviewtable[summary='"+listTitle+"']>tbody>tr").each(function(){       

        $(this).append("<input type='button' value='Help' style='background-color:#0072C5; color:white' class='btnSub'>");

    });

    $("table.ms-listviewtable[summary='"+listTitle+"']>tbody>tr input[value='Help']").click(function(){

        openMail($(this),subjectType);

    });

}

function openMail(btn,subjectType){

    var emailString = "mailto:";

    var emailID = $(btn).prev("td").text()

    //console.log(emailID);

    console.log('openMail:subjectType='+subjectType);


    emailString += emailID ;

    emailString += "?Subject=SharePoint Site Support - Site=";

    emailString += _spPageContextInfo.webServerRelativeUrl;;

    //alert(emailString);

    location.href=emailString;

}


查看完整回答
反對(duì) 回復(fù) 2021-11-12
?
夢(mèng)里花落0921

TA貢獻(xiàn)1772條經(jīng)驗(yàn) 獲得超6個(gè)贊

我建議向click按鈕添加一個(gè)處理程序,而不是使用該onclick屬性,以便您可以明確地傳入所需的參數(shù)。


那是:


const button = $("<input type='button' value='Help' style='background-color:#0072C5; color:white' class='btnSub'>");

button.click(() => openMail(button, subjectType));

$(document).ready(function() {  


    // Get the subject type

    var this_js_script = $('script[src*=AddContactButtons]');

    var subjectType = this_js_script.attr('data-Subject'); 

    if (typeof subjectType == 'undefined' || subjectType == null || subjectType == ''){

      subjectType = "Site";

    }

    //console.log('subjectType='+subjectType);

    addContactButtons(subjectType);

});

function addContactButtons(subjectType){

    var listTitle="Contacts";

    console.log('addcontactButtons:subjectType='+subjectType);

    $(".container").each(function(){

      const button = $("<input type='button' value='Help' style='background-color:#0072C5; color:white' class='btnSub'>");

      button.click(() => openMail(button, subjectType));

      $(this).append(button);

    });

}

function openMail(btn, subjectType){

  console.log('openMail:subjectType='+subjectType);

  /*

  var emailString = "mailto:";

  var emailID = $(btn).prev("td").text()

  //console.log(emailID);

  console.log('openMail:subjectType='+subjectType);


  emailString += emailID ;

  emailString += "?Subject=SharePoint Site Support - Site=";

  emailString += _spPageContextInfo.webServerRelativeUrl;;

  //alert(emailString);

  location.href=emailString;

  */

}

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script type="text/javascript" data-Subject="Site" src="../SiteAssets/js-test/AddContactButtons.js"></script>


<div class="container"></div>

<div class="container"></div>


正如@Bavo 所說(shuō),您當(dāng)前實(shí)施的內(nèi)容存在范圍和上下文問(wèn)題。


查看完整回答
反對(duì) 回復(fù) 2021-11-12
  • 3 回答
  • 0 關(guān)注
  • 200 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)