我的情况是这样的:我能够在不同的 html 页面中从表单中编写文本。但我想做的是只使用该表单中的文本创建一个链接。最初我使用 javascript,尤其是 widget.preferences(一种保存表单中所做更改的方法)和“var”标签:
<script>
addEventListener
(
'DOMContentLoaded',
function()
{
// get the var elements with an id and set their textContent to the corresponding widget.preferences
var vars = document.querySelectorAll( 'var[id]' );
for( var i=0,element=null; element=vars[i++]; )
{
element.textContent = widget.preferences[ element.id ];
}
},
false
);
</script>
</head>
<body>
<h1>Popup window</h1>
<p>Here is a list of preferences and their associated value:</p>
<ul>
<li><var id="foo"></var>
<li><var id="bar"></var>
<li><var id="baz"></var>
<li><var id="check"></var>
<li><var id="group1"></var>
<li><var id="myMultipleSelect"></var>
</ul>
</body>
但是,正如我在开始时所说的,我的目标是使用其他页面上表单中的文本创建链接。表格如下:
<fieldset>
<p>
<input id="text1" name="foo" type="text"></input>
<label for="text1">foo</label>
</p>
<p>
<input id="text2" name="bar" type="text"></input>
<label for="text2">bar</label>
</p>
<p>
<input id="text3" name="baz" type="text"></input>
<label for="text3">baz</label>
</p>
</fieldset>