动态地改变“”的URL;添加新项目”;链接使用javascript/jquery

Change the URL dynamically for "Add New Item" link using javascript/jquery

本文关键字:链接 javascript jquery 新项目 添加 URL 动态 改变      更新时间:2023-09-26

List加载时会在URL中附加?frame=1

http://site/Lists/ListName/AllItems.aspx?iframe=1

单击列表的"添加新项目"链接时,我需要使用javascript/jquery在URL中加载不带?iframe=1的新项目表单。

http://site/Lists/ListName/NewForm.aspx?RootFolder=&IsDlg=1&iframe=1

当前正在尝试使用以下代码,但无法工作。请提出建议。

$(document).on("click","#idHomePageNewItem",function(){
    cururlmod="http://site/Lists/ListName/NewForm.aspx?RootFolder=&IsDlg=1";
    $("#idHomePageNewItem").attr("href", cururlmod);
});

您想在点击时加载一个新的URL吗?

试试这个。当你点击id为"idHomePageNewItem"的标签时,它会在"cururlmod"中加载你的链接。

$("#idHomePageNewItem").on("click",function(){
    cururlmod="http://site/Lists/ListName/NewForm.aspx?RootFolder=&IsDlg=1";
    window.location.href = cururlmod;
});