Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.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 自定义JSP的重新加载_Javascript_Jsp - Fatal编程技术网

Javascript 自定义JSP的重新加载

Javascript 自定义JSP的重新加载,javascript,jsp,Javascript,Jsp,例如,我有一个JSP文件,其中有一些由div确定的选项卡 <div> <ul> <li>Tab1</li> <li>Tab2</li> </ul> <div> tab 1 here </div> <div> tab 2 here </div> </div> 表1 表2 这里是表1 这里是表2

例如,我有一个JSP文件,其中有一些由
div
确定的选项卡

<div>
  <ul>
    <li>Tab1</li>
    <li>Tab2</li>
  </ul>
  <div>
    tab 1 here
  </div>
  <div>
    tab 2 here
  </div>
</div>

  • 表1
  • 表2
这里是表1 这里是表2
现在我在tab2中编写了一些javascript,告诉页面重新加载(
window.location.reload()
)。我需要让新加载的页面将焦点放在选项卡2上,而不是选项卡1上

是否有任何方法可以使用客户端代码自定义重新加载内容

先谢谢你


最好的问候

出于您的目的,您可以使用参数调用页面,该参数告诉您在加载页面时哪个选项卡获得焦点

eg: window.location.href='something.jsp?tab=tab1';
而不是

window.location.reload();
您可以使用参数重新加载页面

window.location=document.url+"?tab=tab2";
window.location.href = <your page here>?focus=2

将位置更改为同一页并发送参数,而不是重新加载

window.location=document.url+"?tab=tab2";
window.location.href = <your page here>?focus=2
设置jsp正文以调用此函数onload:

<body onload="focus()">

function focus() {
    tab = getUrlVars()["focus"]; //this will give you the number of the tab you shall focus
} 

函数焦点(){
tab=getUrlVars()[“focus”];//这将给出要聚焦的选项卡的编号
} 

当您在谈论选项卡集时使用
时,我假设您已经在使用一些Javascript选项卡集实现,这些通常提供您正在寻找的功能(请看一下,添加您当前使用的选项卡集实现可能会很有用)。