Open new browser session

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a button on my web app, that opens a help html page. I use this code:
HttpContext.Current.Response.Write("<script>")
HttpContext.Current.Response.Write("window.open('" & sUrl & "','_new')")
HttpContext.Current.Response.Write("</script>")

This works ok, the html page opens in a new browser window, but when I
close the help, click on a different menu item in my app, and then click the
back button, the help window opens up again.

How do I do a Response.Write, that isn't on HttpContext.Current? I have
also tried _blank

Thanks, Leonard
 
Leonard,

You put window.open(url) in the document - and it executes every time the
document is loaded. If you need to open new window when a button is clicked -
just add "onclick" attribute for your button:
MyButton.Attributes.Add("onclick", "window.open('" & sUrl & "','_new')")
 
Hi Sergey,
The new window opens ok with the code I have, but it opens on the current
context, so when I press the back button, the new url opens again. I want
the window to open, then when I close it, it is gone and is not re-opened
when I press the back button on the browser
 
Leonard,

not sure what you mean, but if you want to prevent the same window from
loading once you navigated to another page, you can store the values whether
you opened or not your window in a hidden field (let's say on document unload
event) and then read that value during load event and then decide whether to
open or not your help window. I used similar techique to prevent a form from
multiposting when user clicks on "Back" or History link.

HTH
 
Back
Top