form.on('select(lang)', function(data){ console.log(data.value); //得到被选中的值 // 获取iframe的链接 var iframeUrl = window.location.href; // 解析URL var url = new URL(iframeUrl); // 获取URL的各个部分 var protocol = url.protocol; // "http:" 或 "https:" var hostname = url.hostname; // "www.example.com" var port = url.port; // "80" 或 "" var pathname = url.pathname; // "/path/to/page.html" var search = url.search; // "?query=string" var hash = url.hash; // "#hash" // 输出URL的各个部分 console.log("Protocol: " + protocol); console.log("Hostname: " + hostname); console.log("Port: " + port); console.log("Pathname: " + pathname); console.log("Search: " + search); console.log("Hash: " + hash); var newurl = pathname+'?lang='+data.value window.location.href = newurl }); form.on('submit(fanyi)', function(data){ var ids = $("#select_data").val(); data.field['ids'] = ids; data.field['molds'] = '{$molds_biaoshi}'; var index = layer.load(1) $.post("{fun U('mutiwebsite/fanyi')}",data.field,function(res){ layer.close(index) layer.msg(res.msg) },'json') return false; });