我有我的硬盘驱动器上的文件.htlm是我的书的列表,并在顶部有一个表单和脚本,让我搜索的文件的内容。 我喜欢当我浏览访问此文件。 我使用Firefox扩展名为“高级网址构建器”这个扩展可以让我强调了几句话,然后使用快捷菜单中选择用... \谷歌或我在编程任何其他网站查找。其中一个是我自己的文件,这将打开光标焦点搜索框,但没有文字就会出现。
当我打开页面的URL看起来是这样的:
file:///F:/MyBooks.htm?search_txt=War and Peace
之后的SEARCH_TEXT? 就是我在“高级网址构建器”等号(=)之后的部分都编程从以前的网站或网页高亮文本
我使用这种形式和脚本,我从一个网站回升:
<form name="search" action="file:///F:/MyBooks.htm" method="post"
onSubmit="if(this.t1.value!=null && this.t1.value!='')
findString(this.t1.value);return false">
<input type="text" name="t1" id="search_txt" size=100 value="" />
<input type="submit" value="Find" name=b1>
</form>
<script language="JavaScript">
<!--
var TRange=null
function findString (str) {
if (parseInt(navigator.appVersion)<4) return;
var strFound;
if (window.find) {
// CODE FOR BROWSERS THAT SUPPORT window.find
strFound=self.find(str);
if (strFound && self.getSelection && !self.getSelection().anchorNode) {
strFound=self.find(str)
}
if (!strFound) {
strFound=self.find(str,0,1)
while (self.find(str,0,1)) continue
}
}
else if (navigator.appName.indexOf("Microsoft")!=-1) {
// EXPLORER-SPECIFIC CODE
if (TRange!=null) {
TRange.collapse(false)
strFound=TRange.findText(str)
if (strFound) TRange.select()
}
if (TRange==null || strFound==0) {
TRange=self.document.body.createTextRange()
strFound=TRange.findText(str)
if (strFound) TRange.select()
}
}
else if (navigator.appName=="Opera") {
alert ("Opera browsers not supported, sorry...")
return;
}
if (!strFound) alert ("String '"+str+"' not found!")
return;
}
//-->
</script>
我需要的是能够给URL的最后部分传递到形式的4号线作为一个变量
<input type="text" name="t1" id="search_txt" size=100 value="War and Peace" />
能否请您帮忙吗?
谢谢。