Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将表单值附加到操作url-动态_Javascript_Html_Forms_Url Routing - Fatal编程技术网

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>