我一直在使用javascript提示在网站上生成报告。您单击链接,这会弹出一个javascript提示符。您键入所需报告的代码,然后生成该报告。
因此,例如,如果您想要报告“ABC123”,当出现提示时,您将键入ABC123并打开“http://example.com/reports/ABC123”
以下代码如下:
function getReport(){
var reportcode = prompt("Report Code : ", "xxx000");
window.open("http://example.com/reports/"+reportcode,"_blank");
return true;
}
这在打开要打印的报告方面非常有效。但我试图将代码更改为重定向到在同一窗口中打开的报表的Web版本,而不是打开一个新窗口。
我认为将“_blank”改为“_self”会实现这一点。但是如果我使用“_self”或“_top”或“_parent”,而不是在同一个窗口中打开报告,它只是重新加载窗口的原始内容。
换句话说,如果我的原始网页为“http://example.com/reports_index”,而不是加载“http://exmaple.com/reports/ABC123”,则只需重新加载“http://example.com/reports_index”。
我无法解释为什么它适用于“_blank”而不适用于“_self”
非常感谢任何想法!
答案 0 :(得分:0)
您可以在同一窗口中使用它进行打开。
window.location.href = "https://example.com/reports/"+reportcode