2014-10-09 61 views
0

在标准的Dot.Net应用程序中,可以添加按钮,可以执行某些功能。OnClick功能在IE 10中不起作用,但在旧版本中正常

点击此按钮后,Google将在新窗口中打开Goog​​le,并在当前窗口中显示输入参数。

<button class="exButton" language="VBS" onclick="MakeReq()">Search Google</button> 
&nbsp; 
<script language="VBS"> 
    Sub MakeReq() 
     window.open "https://www.google.nl/?gws_rd=ssl#q=" & frmMain.FreeTextField_01.Value 
    End Sub 
</script> 

该按钮在IE9或IE10兼容模式下工作正常。 但是在Chrome或IE 10上它不起作用。我没有得到任何回应或可见的错误。

有谁知道:

  1. 失败的原因在IE10的功能?
  2. 更重要的是,我可以如何调整代码以重新运行代码?

请记住,我只能影响这小块脚本,因为页面的其余部分由应用程序的供应商控制。

+1

将VBScript更改为javascript,VBscript在现代浏览器中不受支持。 – Esko 2014-10-09 09:30:30

回答

0

移动到JavaScript中,这样的事情:

<button class="exButton" onclick="MakeReq()">Search Google</button> 
&nbsp; 
<script language="text/javascript"> 
    function MakeReq() { 

     frmMain = document.forms[0]; // if it is the first form 
     textField = frmMain.elements["FreeTextField_01"]; 

     window.open("https://www.google.nl/?gws_rd=ssl#q="+textField.value; 
    } 
</script> 

但它不夹板是什么frmMain.FreeTextField_01.value,所以我试图想象它是在页面的第一个表单字段。

其他方式可以是:

textField = document.getElementsByName("FreeTextField_01")[0]; 

frmMain = document.forms["frmMain"]; 
textField = frmMain.elements["FreeTextField_01"]; 

frmMain = document.forms[0]; // if it is the first form 
textField = frmMain.elements[0]; // if it is the first form element 

frmMain = document.getElementById("frmMain"); 
textField = frmMain.elements["FreeTextField_01"]; 

如果表格有一个ID =“frmMain”

0

感谢您的帮助!下面是结束了为我工作。

<button class="exButton" onclick="myFunction()">Google Search</button> 
<script language="text/javascript"> 
     function myFunction() 
      { 
      frmMain = document.getElementById("frmMain"); 
      textField = frmMain.elements["FreeTextField_01"]; 

      window.open("google.nl/?gws_rd=ssl#q="+textField.value); 
      } 
</script> 
相关问题