我想实现以下目标,衷心感谢您的帮助。
点击按钮:
- 在同一窗口打开目标 url
.show()
特定于该 url
最佳答案
如果您可以控制目标 url,您可以将要显示的 div 的 ID 作为查询传递,然后在加载时获取该 ID 并显示它。
self.location = "nextPage.html?div=foo";
//nextPage.html
document.onload = function(){
if(self.location.search.indexOf("div=") == 0){
document.getElementById(
self.location.search.substring(4)).style.visibility = "visible";
}
}
//nextPage.html body...
<div id="foo" style="visibility:hidden">
如果您无法控制目标 url,那么您将无能为力。
哦,欢迎来到 Stack! :) 如果您发现答案有用,请确保给它们投票并标记它们正确。
关于javascript:打开网址并显示隐藏的div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10761985/