Javascript 将表单值附加到操作url-动态
我有一张这样的表格:Javascript 将表单值附加到操作url-动态,javascript,html,forms,url-routing,Javascript,Html,Forms,Url Routing,我有一张这样的表格: <form action="http://localhost:8080/abc/def/gh" method="post"> var form=document.getElementById(“操作表单”); form.action=form.action.replace(“localhost:8080”,window.location.hostname); var form=document.getElementById(“操作表单”); form.ac
<form action="http://localhost:8080/abc/def/gh" method="post">
var form=document.getElementById(“操作表单”);
form.action=form.action.replace(“localhost:8080”,window.location.hostname);
var form=document.getElementById(“操作表单”);
form.action=form.action.replace(“localhost:8080”,window.location.hostname);
<form action="http://192.222.1.333:8080/abc/def/gh" method="post">
<html>
<body>
<form action="http://localhost:8080/abc/def/gh" id="action-form" method="post"></form>
<script>
var form = document.getElementById("action-form");
form.action = form.action.replace("localhost:8080", window.location.hostname);
</script>
</body>
</html>