Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.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
从url的一部分设置输入框的值_Url_Input - Fatal编程技术网

从url的一部分设置输入框的值

从url的一部分设置输入框的值,url,input,Url,Input,好的,我网站的一部分有这个地址 localhost:2001/?botid=Alice&template=Alice 我想把我放在后面的东西放到页面的输入框里。所以像这样的 localhost:2001/?botid=Alice&template=Alice#您好 你好吗 有人能帮上忙吗 这是源代码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/D

好的,我网站的一部分有这个地址

localhost:2001/?botid=Alice&template=Alice

我想把我放在后面的东西放到页面的输入框里。所以像这样的

localhost:2001/?botid=Alice&template=Alice#您好 你好吗

有人能帮上忙吗

这是源代码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--This is a simple example of an HTML chat template for Program D.-->
    <head>
        <!--The value associated with a bot predicate, such as
            "name", is inserted wherever you use a bot element
            with a name attribute that corresponds to a predicate name.-->
        <title>
            Dialogue with <bot name="name"/>
        </title>
        <!--This is a simple stylesheet to format the page.-->
        <style type="text/css">
            html
            {
            overflow: hidden;
            }
            p
            {
                font-family: Arial, Helvetica, sans-serif;
                font-size: 11px;
                margin-top: 10px;
                margin-bottom: 5px;
                margin-left: 0px;
                margin-right: 10px;
                text-align: left;
                background: transparent;
            }
            .fieldlabel
            {
                font-weight: bold;
                font-style: normal;
                font-size: 14px;
                color: #0000aa;
            }
            #userinput
            {
                font-weight: bold;
                font-style: italic;
                font-size: 14px;
                color: #aa0000;
            }
            .botresponse
            {
                font-weight: bold;
                font-style: italic;
                font-size: 14px;
                color: #00aa00;
            }
            .bottomtext
            {
                margin-top: 0px;
                margin-bottom: 0px;
                font-weight: normal;
                font-style: italic;
                font-size: 10px;
            }
            li p
            {
                margin-top: 0px;
                margin-bottom: 0px;
                margin-left: 20px;
                margin-right: 0px;
            }
            ul
            {
                margin-top: 0px;
                margin-bottom: 5px;
                margin-left: 10px;
                margin-right: 0px;
            }
            form
            {
                margin-top: 20px;
                margin-bottom: 10px;
                margin-left: 0px;
                margin-right: 0px;
            }
            #audio
            {
                display: none;
            }
        </style>
        <script type="text/javascript">
function playPause() {
  var myVideo = document.getElementsByTagName('audio')[0];
  if (myVideo.paused)
    myVideo.play();
  else
    myVideo.play();
}
</script>
<script type="text/javascript">
document.getElementById('text')[0].value = window.location.hash.substring(1);
</script>
    </head>
    <!--The body element is set to automatically give focus to the
        input field each time the document is loaded.-->
    <body>
        <table border="0" cellspacing="5" cellpadding="0" width="500">
            <tr>
                <td width="30%" valign="top">
                    <p class="fieldlabel">
                        You said:
                    </p>
                </td>
                <td width="70%" valign="top">
                    <p id="userinput">
                        <userinput/>
                    </p>
                </td>
            </tr>
            <tr>
                <td width="30%" valign="top">
                    <p class="fieldlabel">
                        <!--The name of the bot will be substituted here.-->
                        <bot name="name"/> said:
                    </p>
                </td>
                <td width="70%" valign="top">
                    <p class="botresponse">
                        <!--The bot's response will be substituted here.-->
                        <reply></reply><response/>
                    </p>
                </td>
            </tr>
            <tr>
                <td width="100%" colspan="2" valign="top">
                    <form method="post">
                        <input type="text" size="50" name="text" id="text" onkeydown="if (event.keyCode == 190) document.getElementById('go').click()" x-webkit-speech />
                        <input type="submit" id="go" value="Say" />
                    </form>
                </td>
            </tr>
            <tr>
                <td width="100%" colspan="2" valign="top">
                    <p class="bottomtext">
                        <!--Again we display the bot name, and also the hostname.-->
                        You are speaking with <bot name="name"/> from <hostname/>.
                    </p>
                    <p class="bottomtext">
                        <!--Here is an example of getting another bot predicate value (master).-->
                        <bot name="name"/>'s botmaster is <bot name="master"/>.
                    </p>
                    <p>
                        You can:
                    </p>
                    <ul>
                        <li>
                            <p>
                                <!--This link will request a login form.-->
                                <a href="?login=yes">log in</a>.
                            </p>
                        </li>
                        <li>
                            <p>
                                <!--This link will request a new user registration form.-->
                                <a href="?register=yes">register a new username and password</a>.
                            </p>
                        </li>
                    </ul>
                </td>
            </tr>
        </table>
<audio id="audio" onended="document.forms[0].elements[0].focus();" controls="controls" autoplay="autoplay" src="http://translate.google.com/translate_tts?tl=en&q=><response/>" type="audio/mpeg"></audio>
    </body>
</html>

对话
html
{
溢出:隐藏;
}
P
{
字体系列:Arial、Helvetica、无衬线字体;
字体大小:11px;
边缘顶部:10px;
边缘底部:5px;
左边距:0px;
右边距:10px;
文本对齐:左对齐;
背景:透明;
}
.fieldlabel
{
字体大小:粗体;
字体风格:普通;
字体大小:14px;
颜色:#0000aa;
}
#用户输入
{
字体大小:粗体;
字体:斜体;
字体大小:14px;
颜色:#aa0000;
}
.博特回应
{
字体大小:粗体;
字体:斜体;
字体大小:14px;
颜色:#00aa00;
}
.bottomtext
{
边际上限:0px;
边缘底部:0px;
字体大小:正常;
字体:斜体;
字体大小:10px;
}
李平
{
边际上限:0px;
边缘底部:0px;
左边距:20px;
右边距:0px;
}
保险商实验室
{
边际上限:0px;
边缘底部:5px;
左边距:10px;
右边距:0px;
}
形式
{
边缘顶部:20px;
边缘底部:10px;
左边距:0px;
右边距:0px;
}
#音频
{
显示:无;
}
函数playPause(){
var myVideo=document.getElementsByTagName('audio')[0];
如果(myVideo.paused)
myVideo.play();
其他的
myVideo.play();
}
document.getElementById('text')[0]。value=window.location.hash.substring(1);

你说:

说:

您正在与来自的联系人通话。

的僵尸主人是。

你可以:

  • .

  • .

使用jQuery:

$('input').val(window.location.hash.substring(1));
没有jQuery:

document.getElementsByTagName('input')[0].value = window.location.hash.substring(1);
无论哪种方式,都必须确保加载了DOM。如果您想取消景观,请使用例如:


window.location=window.location+'#'+document.getElementById('inputbox').text

我需要喜欢我的网站上的jquary js吗?@Trevor,不,没有库你也可以。焦点需要放在文本框上吗?不,没关系。但是,您必须确保页面已加载。这是safari给我的错误,
“document.getElementById('text')”[null]不是对象。
window.addEventListener("load", function()
{
    document.getElementsByTagName('input')[0].value = decodeURIComponent(window.location.hash.substring(1));
}, false);